Linux install MySQL default root cannot log on the problem

Source: Internet
Author: User

Problem:


[Email protected] mysql]# mysql-u root-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)

Workaround:
Method One:
#/etc/init.d/mysql Stop
# Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
# mysql-u Root MySQL
mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root ';
mysql> FLUSH privileges;
Mysql> quit
#/etc/init.d/mysql Restart
# mysql-uroot-p
Enter Password: < Enter the newly set password newpassword>
Mysql>


Method Two:
Use the user name and password provided directly in the [client] section of the/etc/mysql/debian.cnf file:
# mysql-udebian-sys-maint-p
Enter Password: < Enter the password for the [client] section >
mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root ';
mysql> FLUSH privileges;
Mysql> quit
# mysql-uroot-p
Enter Password: < Enter the newly set password newpassword>
Mysql>

After the above method executes, login MySQL also need to set the password, otherwise you can not do other operations, prompted to set the password
Set Password=password (' Weixiao ');

MySQL installed after the directory under Linux
1. Database Directory
/var/lib/mysql/

2. Configuration files
/usr/share/mysql (mysql.server command and configuration file)

3. Related commands
/usr/bin (Mysqladmin mysqldump and other commands)

4. Startup script
/etc/init.d/mysql start|stop|restart|status (startup script file mysql directory)

After Linux has installed the service, open port command:

/sbin/iptables-i input-p TCP--dport 9090-j ACCEPT; (Case sensitive)

Then enter the following command to view the port:

/etc/init.d/iptables status

Finally, you need to save and restart the firewall

/etc/rc.d/init.d/iptables Save (Save)

Service iptables Restart (restart)

Everything OK, can be accessed remotely

********************************************************

This error is reported when using the MySQL tool for remote access:

Host is not allowed to connect to this MySQL server

This is because there is no authorization if you want to connect to the MySQL server from any host.

Grant all privileges on * * to ' root ' @ '% ' identified by ' Weixiao ' with GRANT option;

If you want to allow only users to connect to the MySQL server from a fixed IP host.

Grant all privileges on * * to ' root ' @ ' 170.12.12.155 ' identified by ' Weixiao ' with GRANT option;

Linux install MySQL default root cannot log on the problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.