Linux-centos-64bit安装MySQL

半腔热情 提交于 2020-02-02 06:32:37

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/mysql1.赋予可执行权限[root@VM_0_9_centos mysql]# chmod +x /etc/init.d/mysql2.添加服务[root@VM_0_9_centos mysql]# chkconfig --add mysql3.显示服务列表[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.cnf1.在[mysqld]后面任意一行添加“skip-grant-tables”2.在[mysqld]上面加入下面两句话[client] default-character-set=utf83.在[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
  

 



 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!