Install Mysql database on Linux

Source: Internet
Author: User

Install Mysql database on Linux
Check whether the installation has been installed:

 yum list installed mysql* rpm -qa|grep mysql* 

Check whether the installation package is available:
 yum list mysql* 

Install the mysql client:
 yum install mysql 

Install the mysql server:
yum install mysql-server yum install mysql-devel

Start & stop database character set settings
Mysql configuration file/etc/my. add default-character-set = utf8 to cnf to start mysql service: service mysqld start or/etc/init. d/mysqld start: add boot start: chkconfig -- add mysqld; start: chkconfig mysqld on; check whether the boot settings are successful chkconfig -- list | grep mysql * mysqld 0: disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable stop: service mysqld stop

Change logon Password

MySQL does not have a password by default. It is self-evident that the password is added after installation.

1. Commands
[root@localhost]# mysqladmin -u root password 'new-password' 

Format: mysqladmin-u username-p old password New password


2. Example
Example 1: Add a 123456 password to the root user.
Type the following command:
[root@localhost]#mysqladmin -u root password 123456 

Note: because the root account does not have a password at the beginning, the old-p password can be omitted.


3. test whether the modification is successful

1) login without a password
[root@localhost]#  mysql ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO) 

An error is displayed, indicating that the password has been modified.


2) log on with the modified Password
[Root @ localhost] # mysql-u root-p Enter password: (Enter the modified password 123456) Welcome to the MySQL monitor. commands end with; or g. your MySQL connection id is 4 to server version: 4.0.16-standard Type 'help; 'or 'H' for help. type 'C' to clear the buffer. mysql>
Successful!


Host... is not allowed to connect to this MySql server

To log on to another computer as a root user, perform the following actions:

Run the following command on the machine where mysql is installed:

1. [root @ localhost] # mysql-h localhost-u root-p // you can access the MySQL server 2. mysql> grant all privileges on *. * TO 'root' @ '%' with grant option // GRANT data access permissions TO any host. 3. mysql> flush privileges // The modification takes effect. 4. mysql> EXIT // EXIT MySQL. server


In this way, you can log on to any other host as the root user!

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.