MySQL源码编译和安装配置

参考MySQL官方文档,链接如下:
http://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html

源码编译完成后,需要进行如下工作:

1、修改数据库基本配置
/etc/my.cnf

[mysqld]
# 默认存放位置,修改成你希望存放的位置 
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# 此处为增加的内容,解决安装后mysql无法连接的问题
[client]
port=3306
socket=/var/lib/mysql/mysql.sock

2、修改初始密码
可以使用如下所列任意一种方法。

mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysql123';

mysql>UPDATE mysql.user SET Password=PASSWORD('mysql123') where USER='root' and host='root' or host='localhost';

mysql>SET PASSWORD = PASSWORD('mysql123'); 

3、增加root用户的远程访问

mysql>UPDATE user SET host='%' WHERE user='root';
mysql>FLUSH PRIVILEGES; 

4、启动服务

shell>service mysql.server start

你可能感兴趣的:(数据库,mysql)