mysqlにログインできない

# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
心当たりを入力しても解決できず。

そんな時はセーフモードで起動し再設定を行う。
# service mysqld stop
mysqld does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
# mysqld_safe –skip-grant-tables &
[1] 3342

# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.4.3 Source distribution
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
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.

root@localhost [(none)]> use mysql;
Database changed
root@localhost [mysql]> set password for root@localhost = ‘********’;
Query OK, 0 rows affected (0.05 sec)
root@localhost [mysql]> flush privileges;
Query OK, 0 rows affected (0.01 sec)
root@localhost [mysql]> quit

# service mysqld stop
mysqld does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
# service mysqld start
mysqld does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
# service mysql-server status
# mysql is running as pid 3276.
起動はservice mysql-server startでもいいのでしょうね。起動と停止は。
とりあえずここまで。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)