MYSQL Access denied for user 'root'@'localhost'

后端 未结 3 1683
我寻月下人不归
我寻月下人不归 2020-12-11 15:49

I did the following steps to use MySQL in Ubuntu:

sudo aptitude install php5-mysql mysql-server
sudo service mysql stop
sudo mysqld_safe --skip-grant-tables          


        
3条回答
  •  时光说笑
    2020-12-11 16:11

    If you get an error message like this:

    Warning: mysql_connect(): Access denied for user: ....
    

    then the problem is that your application can not access the database. This can have several causes:

    First of all, make sure the database settings in your db-config.php (connection file for your application) are correct, specifically the name and password of your MySQL user, the name of your database, and the name of your MySQL server.

    If you're running your own server, you may need to give your MySQL user proper permissions. Log in to MySQL as the MySQL root user and issue these commands:

    GRANT ALL PRIVILEGES ON database_name TO user@host IDENTIFIED BY 'password';
    FLUSH PRIVILEGES;
    

提交回复
热议问题