shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell>cd /usr/local
shell>tar zxvf
shell>/path/to/mysql-VERSION-OS
.tar.gzln -s
shell>full-path-to-mysql-VERSION-OS
mysqlcd mysql
shell>mkdir mysql-files
shell>chmod 750 mysql-files
shell>chown -R mysql .
shell>chgrp -R mysql .
shell>bin/mysql_install_db --user=mysql
# Before MySQL 5.7.6 shell>./bin/mysqld --initialize --user=mysql --datadir=/home/mysql/mysql3316/data/ # MySQL 5.7.6 and up
2016-08-03T09:04:12.255526Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-03T09:04:12.538185Z 0 [Warning] InnoDB: New log files created, LSN=457902016-08-03T09:04:12.592864Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2016-08-03T09:04:12.605358Z 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: 3f0b6c52-5959-11e6-8c68-00163e415703.2016-08-03T09:04:12.606217Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.2016-08-03T09:04:12.607201Z 1 [Note] A temporary password is generated for [email protected]: w+&E:13EZDnq shell>./bin/mysql_ssl_rsa_setup --datadir=/home/mysql/mysql3316/data/ # MySQL 5.7.6 and up shell>chown -R root .
shell>chown -R mysql data mysql-files
shell>bin/mysqld_safe --user=mysql &
# Next command is optional shell>cp support-files/mysql.server /etc/init.d/mysql.server
shell> mysql -uroot -p‘w+&E:13EZDnq‘ -hlocalhost --socket=/tmp/mysql3316.sock --port=3316
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password = password(‘mypass‘); //一定要设置一下新密码
还有一种情况,就是不知道初始化密码vi /etc/my.cnf在[mysqld]下面增加一行skip-grant-tables重启 /etc/init.d/mysqld restart /usr/local/mysql/bin/mysql -uroot mysql> update user set authentication_string=password(‘123333‘) where user=‘root‘;退出来后,更改my.cnf,去掉刚加的 skip-grant-tables重启 /etc/init.d/mysqld restart 此时就可以使用新的密码了。
时间: 2024-10-10 07:19:44