6

mysql安装步骤(5)5.7安装

 2 years ago
source link: https://wakzz.cn/2018/03/15/mysql/%E5%AE%89%E8%A3%85%E6%AD%A5%E9%AA%A4(5)5.7%E5%AE%89%E8%A3%85/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

mysql安装步骤(5)5.7安装

祈雨的博客
2018-03-15

1、准备文件

  1. mysql5.7.20及boost依赖

    2.1、解压mysql

    tar -zxvf mysql-5.7.20.tar.gz

2.2、添加boost

mysql5.7依赖boost,编译mysql时需要指定boost所在文件夹。

mkdir mysql-5.7.20/boost
cp boost_1_59_0.tar.gz mysql-5.7.20/boost/

2.3、配置

指定mysql的安装路径和boost的所在路径

cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/opt/mysql/data -DSYSCONFDIR=/opt/mysql/conf -DMYSQL_UNIX_ADDR=/opt/mysql/mysql.sock -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_BOOST=/opt/mysql-5.7.20/boost

2.4、编译

make
make install

3、安装数据库

3.1、初始化数据库

mysql5.7初始化数据库时会自动为超级用户生成一个包含随机密码的文件,需要通过–random-password-file参数指定随机密码文件的路径。

cd /opt/mysql
./bin/mysql_install_db --user=root --basedir=/opt/mysql/ --datadir=/opt/mysql/data/ --random-password-file=/opt/mysql/password

3.2、添加配置文件

vim ./my.cnf
添加配置文件并添加如下内容:

[mysqld]
basedir = /opt/mysql
datadir = /opt/mysql/data
# port = .....
# server_id = .....
socket = /opt/mysql/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

3.3、启动数据库

nohup ./bin/mysqld --defaults-file=/opt/mysql/my.cnf &

4、远程访问授权

读取随机密码文件获取root用户的初始密码cat ./password
登录mysql

./bin/mysql -uroot -p

修改root用户密码:

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

添加远程权限

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK