Linux MySQL5.7.18安装手册
1.安装依赖包
yum install libaio library -y
2.新建用户组和用户
groupadd mysql
useradd mysql -g mysql
3.解压到data下面
tar -zxvf /data/software/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /data
4 重命名
mv mysql-5.7.18-linux-glibc2.5-x86_64/ mysql
5.安装
cd mysql/
mkdir data
6.更改所有者以及授权755权限
cd ../
chown -R mysql:mysql mysql/
chmod -R 755 mysql/
cd mysql
./bin/mysqld --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data –initialize
7.测试
执行
./support-files/mysql.server start
如果提示下面错误
./support-files/mysql.server: line 239: my_print_defaults: command not found
./support-files/mysql.server: line 259: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
那就正常了
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
设置环境变量
echo 'PATH=/data/mysql/bin/:$PATH' >>/etc/profile
source /etc/profile
8.配置my.cnf下面是my.cnf的具体配置
[client]
socket =/data/mysql/mysql.sock
port=3306
[mysql]
default-character-set=utf8
[mysqld]
basedir=/data/mysql
datadir=/data/mysql/data
port=3306
pid-file=/data/mysql/mysqld.pid
skip-name-resolve
socket = /data/mysql/mysql.sock
character-set-server=utf8
default-storage-engine=INNODB
explicit_defaults_for_timestamp = true
server-id=1
skip-grant-tables=1
9.修改密码接下来就是重点了修改密码,需要修改两次,一次authentication_string,一次 password
update mysql.user set authentication_string=password('vv@122') where user='root' and Host = 'localhost';
flush privileges;
特别提醒注意的一点是,新版的mysql数据库下的user表中已经没有Password字段了
而是将加密后的用户密码存储于authentication_string字段
然后把之前的配置skip-grant-tables=1去掉,重新启动mysql
上面是多条件精确更改数据库密码,也可以执行下面精简版本
ALTER USER 'root'@'localhost' IDENTIFIED BY 'vv@122';
flush privileges;
10 添加用户并授权
grant all privileges on *.* to ‘vv’@'%' identified by 'vv@122';
flush privileges;