问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
- 1045密码错误,所以先将 mysql 密码和 phpMyAdmin 保持一致
- 改密过程: net stop mysql关闭服务
修改mysql文件: vim /etc/my.cnf
在mysqld 块末尾添加: skip-grant-tables 进去免密登录
mysql -u root -p
update user set password=password("root") where user="root"
flush privileges
- 修改后出现
mysqli::real_connect(): (HY000/2002): Connection refused - 解决方案:
把/opt/lampp/phpmyadmin路径下的config.inc.php文件,使用config.sample.inc.php文件代替。
即把原先的 config.inc.php 文件备份,把 config.sample.inc.php 修改成 config.inc.php 。
总之将下面的配置保持一致即可
config.sample.inc.php :
*******
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
******
完成!
情况二:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38) 解决过程:
cd /www/server/mysql/
sudo ./support-files/mysql.server start
如果启动报错: . ERROR! The server quit without updating PID file (/usr/local/var/mysql/bogon.p 则可能是没有bogon/没有权限,我们给予权限即可 执行:
sudo chmod -R 777 /usr/local/var/mysql/
启动后发现tmp 下就有了一个mysql.sock ,再连接数据库。ok 连接成功
情况三:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
|