Linux-centos-64bit安装MySQL

1.下载mysql安装包到 /usr/local/soft

[root@VM_0_9_centos ~]# cd /usr/local/soft
[root@VM_0_9_centos soft]# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

2.安装依赖环境

[root@VM_0_9_centos soft]# yum -y install perl perl-devel autoconf libaio

3.解压安装包

[root@VM_0_9_centos soft]# tar zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

4.移动安装包至 /usr/local 下,并修改文件夹名为 mysql

[root@VM_0_9_centos soft]# mv mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql

5.添加系统mysql组和mysql用户

[root@VM_0_9_centos mysql]# groupadd mysql
[root@VM_0_9_centos mysql]# useradd -r -g mysql -s /bin/false mysql

6.进入 /usr/local/mysql 修改目录拥有者为mysql用户

[root@VM_0_9_centos mysql]# chown -R mysql:mysql ./

7.进行安装

[root@VM_0_9_centos mysql]# ./scripts/mysql_install_db --user=mysql

8.修改当前目录拥有者为root用户

[root@VM_0_9_centos mysql]# chown -R root:root ./

9.修改当前data目录拥有者为mysql用户

[root@VM_0_9_centos mysql]# chown -R mysql:mysql ./data

10.添加mysql服务开机自启动

[root@VM_0_9_centos mysql]# cp support-files/mysql.server /etc/init.d/mysql
1.赋予可执行权限
[root@VM_0_9_centos mysql]# chmod +x /etc/init.d/mysql
2.添加服务
[root@VM_0_9_centos mysql]# chkconfig --add mysql
3.显示服务列表
[root@VM_0_9_centos mysql]# chkconfig --list

11.启动mysql服务

1.创建缺少的文件夹
[root@VM_0_9_centos mysql]# mkdir /var/log/mariadb
2.启动mysql服务
[root@VM_0_9_centos mysql]# service mysql start

12.添加软连接

[root@VM_0_9_centos mysql]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
[root@VM_0_9_centos mysql]# ln -s /usr/local/mysql/bin/mysqldump /usr/local/bin/mysqldump

解决ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2),建立一个软连接:
[root@VM_0_9_centos mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

13.配置my.ini 打开/etc/my.cnf 

[root@VM_0_9_centos mysql]# vim /etc/my.cnf

1.在[mysqld]后面任意一行添加“skip-grant-tables”
2.在[mysqld]上面加入下面两句话
[client] 
default-character-set=utf8
3.在[mysqld]最下面加入下面几句话
default-storage-engine=INNODB 
character-set-server=utf8 
collation-server=utf8_general_ci
  

 14.保存 /etc/my.cnf 并重启mysql 服务器

[root@VM_0_9_centos mysql]# service mysql restart

15.修改root登录密码

[root@VM_0_9_centos mysql]# mysql
  

 


 

posted @ 2019-07-20 17:39  任余涛  阅读(262)  评论(0编辑  收藏  举报