After installing mysql: 1. Start the mysql service and report an error 2. Modify the password and report an error

After the author upgraded mysql5.5 to 5.7, he encountered two errors and started to fill in the pits.

1. Start the mysql service and report an error

Execute service mysqld start and report an error:

Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

1) Check the log, only look at the error

cat /var/log/mysqld.log

Discover:

 [ERROR] Can’t start server: Bind on TCP/IP port: Address already in use
 [ERROR] Do you already have another mysqld server running on port: 3306

Translation: The port is occupied, have you already run other mysqld services occupying 3306

2) Check the port status

netstat -apn | grep 3306

Discover:

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      7461/mysqld

solve:

kill 7461
service mysqld restart

2. An error is reported when changing the password

Execute set password for 'root'@'localhost' =password('root'); Error:

ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 42. Created with MySQL 50568, now running 50737. Please use mysql_upgrade to fix this error.

1) After manually upgrading mysql, the data structure has changed, so it must be upgraded through instructions

mysql> quit
mysql_upgrade
service mysqld restart

At this point, the author window returns:

Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
mysql_upgrade: (non fatal) [ERROR] 1728: Cannot load from mysql.proc. The table is probably corrupted
mysql_upgrade: (non fatal) [ERROR] 1545: Failed to open mysql.event
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Upgrading the sys schema.
Checking databases.
sys.sys_config                                     OK
Upgrade process completed successfully.
Checking if update is needed.

2) Install mysql for the first time, log in to the database and directly enter without entering a password

mysql -u root -p
# 直接按回车
mysql> set password for 'root'@'localhost' =password('root');
# 设置数据库用户root的密码为root

3) Test login password

mysql> exit
mysql -u root -p
Enter password:
# 输入root,并回车
# 登录成功!

Guess you like

Origin blog.csdn.net/qq_17685725/article/details/126714983