mysql-5.7.9安装

版本:mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz(编译版本) 
解压: tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.9-linux-glibc2.5-x86_64   /data/mysql
创建用户:
sudo groupadd mysql
sudo useradd -g mysql -d /home/mysql mysql
初始化:
./bin/mysqld --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data  --initialize
#打印信息:
2016-12-28T08:45:27.382016Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-12-28T08:45:27.386016Z 0 [Warning] One can only use the --user switch if running as root

2016-12-28T08:45:28.032586Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-12-28T08:45:28.404826Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-12-28T08:45:28.457748Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: fbb95bce-ccd9-11e6-84f8-326539313031.
2016-12-28T08:45:28.462726Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-12-28T08:45:28.465159Z 1 [Note] A temporary password is generated for root@localhost: U#jhFavOj88W(初始化的密码)
开启mysql:
./support-files/mysql.server start
报错:
./support-files/mysql.server: line 276: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
mysql的tar.gz安装包的默认安装目录为/usr/local/mysql, 这时候我们需要修改/support-files/mysql.server文件的basedir和datadir目录路径为我们环境所在的mysql的basedir和datadir路径
创建软连接:
ln -s /home/mysql/bin/mysql /usr/bin/mysql
复制配置文件到etc/
sudo cp support-files/my.cnf  /etc/my.cnf
开机启动:
cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
# chkconfig --list mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
开启:
service mysqld start
 cd /home/mysql
 开启:
# ./bin/mysqld_safe --skip-grant-tables --skip-networking&
[1] 6225
[root@localhost mysql]# 151110 02:46:08 mysqld_safe Logging to '/home/mysql/data/localhost.localdomain.err'.
151110 02:46:08 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data
登录设置密码:
# mysql -u root mysql
update user set authentication_string = PASSWORD('123456') where user = 'root'
service mysqld start
登录:mysql -uroot -p
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决办法:
ALTER USER 'root'@'localhost' IDENTIFIED BY '*********'

  

原文地址:https://www.cnblogs.com/byteworld/p/6231545.html