linux上安装 mysql5.6

Posted Philly008

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux上安装 mysql5.6相关的知识,希望对你有一定的参考价值。

1. 创建用户及组

cd /
groupadd mysql
useradd -g mysql mysql
passwd mysql
chown -R mysql:mysql /usr/local

2. 解压安装包

cd /usr/local/
tar -zxvf mysql5.6.tar.gz

3. 配置 /usr/local/mysql/my.cnf

[client]
default-character-set=utf8
socket=/usr/local/mysql/tmp/mysql.sock
[mysql]
default-character-set=utf8
[mysqld]
socket=/usr/local/mysql/tmp/mysql.sock
tmpdir=/usr/local/mysql/tmp/
max_allowed_packet=1024M
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
symbolic-links=0
character_set_server=utf8
[mysqld_safe]
default-character-set=utf8
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/run/mysqld/mysqld.pid

4. 授权

chmod 777 my.cnf

5. 初始化配置文件

cd /usr/local/mysql
scripts/mysql_install_db --user=mysql --defaults-file=/usr/local/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/

6. 配置MySQL启动文件

cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
service mysqld start        # 启动
service mysqld stop        # 停止

出现的问题解决办法

1. 解决Access denied for user ‘‘@‘localhost‘ to database ‘mysql
原因是mysql的密码有问题
用mysql匿名用户可以进入数据库,但是看不见mysql数据库.
解决办法:
具体操作步骤:
关闭mysql:
# service mysqld stop
然后:
# mysqld_safe --skip-grant-tables
启动mysql:
# service mysqld start
mysql -u root
mysql> use mysql
mysql> UPDATE user SET Password=PASSWORD(‘xxx‘) WHERE user=‘root‘;
mysql> flush privileges;
mysql>q

到这里密码已经修改成功,
mysql -u root -p

2. MySQL启动出现The server quit without updating PID file错误解决办法
将 /etc/mysql 下的 my.cnf 文件删除,再次启动MySQL服务

以上是关于linux上安装 mysql5.6的主要内容,如果未能解决你的问题,请参考以下文章

下载mysql5.6源码在linux下安装

CentOS7.4上2分钟快速安装MySQL5.6

Centos6.6上安装mysql5.6

Centos7安装并配置mysql5.6完美教程

Centos7安装并配置mysql5.6完美教程

MYSQL5.6.16版本源代码编译安装