[root@i-2pcc1lv7 mysql]# cd /usr/local/mysql/bin[root@i-2pcc1lv7 bin]# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
2020-08-31T12:05:17.393228Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).
2020-08-31T12:05:17.679400Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-08-31T12:05:17.728911Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-08-31T12:05:17.787713Z 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: 3c486de7-eb82-11ea-96cd-525401e3f0a7.
2020-08-31T12:05:17.789865Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-08-31T12:05:17.790726Z 1 [Note] A temporary password is generated for root@localhost: cr#5<Ftky%Y1
[root@i-2pcc1lv7 bin]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.2020-08-31T12:10:10.685085Z mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
The server quit without updating PID file(/usr/local/mysql[FAILED]2pcc1lv7.pid).
#遇到如上报错,因为没有路径也没有权限,所以创建此路径并授权给mysql用户[root@i-2pcc1lv7 bin]# mkdir /var/log/mariadb[root@i-2pcc1lv7 bin]# touch /var/log/mariadb/mariadb.log[root@i-2pcc1lv7 bin]# chown -R mysql:mysql /var/log/mariadb#再次启动MySQL服务器[root@i-2pcc1lv7 bin]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL. [ OK ]
添加软连接,并重启mysql服务
[root@i-2pcc1lv7 bin]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql[root@i-2pcc1lv7 bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql[root@i-2pcc1lv7 bin]# service mysql restart
Shutting down MySQL..[ OK ]
Starting MySQL. [ OK ]
登录mysql,修改密码
[root@i-2pcc1lv7 bin]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
mysql>set password for root@localhost = password('126315');
Query OK, 0 rows affected, 1 warning (0.00 sec)
开放远程连接
mysql> use mysql;
Database changed
mysql> update user set user.Host='%' where user.User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)