mysql服务端安装,忘记密码
http://dev.mysql.com/downloads/mysql
参考 https://www.cnblogs.com/linglei/p/14519416.html
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
groupadd mysql
useradd -r -g mysql mysql
tar xvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql
mv mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
得到密码
[Note] A temporary password is generated for root@localhost: !RKTMp<Y458*
vi /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
lower_case_table_names=1
character_set_server=utf8
##skip-grant-tables
[ mysql ]
default-character-set=utf8
配置快捷键
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart
忘记密码处理~~~~~~~~~~~~
编辑/etc/my.cnf
[mysqld]添加如下
skip-grant-tables
/etc/init.d/mysqld restart
/usr/bin/mysql启动
修改密码
###UPDATE mysql.user SET Password=PASSWORD('zzx123456') where USER='localhost'; #mysql5.7 Password已改为authentication_string
update MySQL.user set authentication_string=password('root') where user='localhost' ;
/etc/init.d/mysqld restart 最后重启验证密码
mysql -u localhost -p
root