UbuntuMySQL installation and User Logon

Source: Internet
Author: User
Tags mysql view
To install MySQL in Ubuntu, run the following command at a terminal prompt: sudoapt-getinstallmysql-servermysql-client # midway will let you enter a root user password sudoapt-getinstallphp5-mysql # installation php5-mysql is to connect php and mysql once the installation is complete, the MySQL server should start automatically.

Install MySQL in Ubuntu

To install MySQL, run the following command at a terminal prompt:

Sudo apt-get install mysql-server mysql-client # midway will let you enter a root user password sudo apt-get install php5-mysql # installation php5-mysql is to connect php and mysql once installation is complete, the MySQL server should be started automatically.

Sudo start mysql # start sudo stop mysql manually # stop it manually. After you modify the configuration file, restart mysqld to make the changes take effect.

To check whether the mysqld process is enabled, run the following command:

Pgrep mysqld if the process is enabled, this command returns the id of the process.

Ps-A | grep mysql

If processes such as mysqld and mysqld_safe exist, they are displayed, for example:

4460 pts/0 00:00:00 mysqld_safe
4583 pts/0 00:00:01 mysqld

Logon to MySQL:

(1) mysql-u root-p

After the password is entered, the ERROR message is as follows: ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: YES), indicating that the root password is incorrect.

The solution is as follows:

A. sudo mysqld_safe -- user = root -- skip-grant-tables -- skip-networking &

After you enter the command, the following message is displayed:

[1] 5166
Root @ www.linuxidc.com:/home/jung #120521 18:46:32 mysqld_safe Logging to syslog.
120521 18:46:32 mysqld_safe Starting mysqld daemon with databases from/var/lib/mysql

If the prompt is:

[2] 4928
Root @ www.linuxidc.com:/home/jung #120521 18:44:40 mysqld_safe Logging to syslog.
120521 18:44:40 mysqld_safe A mysqld process already exists

Indicates that the mysqld_safe process exists.

Ps-A | grep mysql view the mysqld_safe process ID

Kill-9-xxxx terminate the process with the ID xxxx

Run the following command:

Mysql-u root mysql indicates logging on to the mysql database as a root user

Select * from user; you can see details such as the registered user name and password. The root password is www.linuxidc.com.

In fact, we enter

Mysql-u root-p

Enter password: www.linuxidc.com

ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: YES)

Modify the root password again:

Update user set password = PASSWORD ('www .linuxidc.com ') where user = 'root' and host = 'localhost ';

Flush privileges; this statement is required. Otherwise, you cannot log on to the mysql client.

(2) New users cannot log on

After logging on to the mysql database as the root user, you can create a local user named jun. After the client is launched, the user can log on to the database using jun with an error message.

ERROR 1045 (28000): Access denied for user 'wujun' @ 'localhost' (using password: YES)

This error mainly involves the following highlights:

A. When a new user is created, the PASSWORD is input in the format of 'xxxxxx' rather than in the form of PASSWORD ('xxxxxx ').

Correct statement:

Mysql> insert into user (host, user, password) values ('local', jun, PASSWORD ('xxxxxx '));


Mysql> flush privileges;

B. After a correct insert statement is entered, no input is made.

Mysql> flush privileges;

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Related Article

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.