Install and configure MySQL in centOS6.5, centos6.5mysql

Source: Internet
Author: User
Tags ssh secure shell

Install and configure MySQL in centOS6.5, centos6.5mysql

Install and configure MySQL in centOS6.5


1. SSH Secure Shell Client

First, install the SSH Secure Shell Client, a tool for connecting to a remote Linux system, or an SSH Client for short.

After setting the IP address and port number on the Linux host, open the SSH Client, click Quick Connect, and fill in the IP address, user name (usually root by default), and port number of the remote service.

After entering the system, Add Profile appears. You can enter a name as the ID, which is a convenient way to log on without using the user name in the future.


2. MySQL

I. Installation

<Span style = "font-size: 12px;"> [root @ sample ~] # Yum-y install mysql-server // install MySQL [root @ sample ~] # Yum-y install php-mysql // install php-mysql </span>

Ii. Start

<Span style = "font-size: 12px;"> [root @ sample ~] #/Etc/rc. d/init. d/mysqld start // start the MySQL service Initializing MySQL database: [OK] Starting MySQL: [OK] </span>

3. Set a password for the root user

When MySQL was just installed, its root user was not set a password. First, set the MySQL root Password.


[Root @ sample ~] # Mysql-u root login use the root user to log on to the MySQL server
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2 to server version: 4.1.20

Type 'help; 'or' \ H' forhelp. Type '\ C' to clear the buffer.

Mysql> select user, host, password from mysql. user; login view user information
+ ------ + ------------------------------ + --------------- +
| User | host | password |
+ ------ + ------------------------------ + --------------- +
| Root | localhost | the guest root password is blank.
| Root | sample.centospub.com | the guest root password is blank.
| Sample.centospub.com |
| Localhost |
+ ------ + ------------------------------ + --------------- +
4 rows in set (0.00 sec)

Mysql> set password for root @ localhost = password ('Enter the root password' here); then set the root password
Query OK, 0 rows affected (0.01 sec)

Mysql> set password for root @ 'sample .centospub.com '= password ('Enter the root password' here); configure the root password
Query OK, 0 rows affected (0.01 sec)

Mysql> select user, host, password from mysql. user; login view user information
+ ------ + ----------------------------------- + -------------------------------- +
| User | host | password |
+ ------ + ----------------------------------- + -------------------------------- +
| Root | localhost | 19b68057189b027f | the guest root password is set.
| Root | sample.centospub.com | 19b68057189b027f | the ← root password is set.
| Sample.centospub.com |
| Localhost |
+ ------ + ----------------------------------- + -------------------------------- +
4 rows in set (0.01 sec)

Mysql> exit MySQL Server
Bye


Then, test whether the root password has taken effect.


[Root @ sample ~] # Mysql-u root login log on with a blank password
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO) indicates that the password is successfully set.
[Root @ localhost ~] # Mysql-u root-h sample.centospub.com login log on with root using an empty password
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO) indicates that the password is successfully set.
[Root @ sample ~] # Mysql-u root-p login using the password to log on as root
Enter password: Enter password here
Welcome to the MySQL monitor. Commands end with; or \ g. login confirm that you can log on with the password
Your MySQL connection id is 5 to server version: 4.1.20

Type 'help; 'or' \ H' forhelp. Type '\ C' to clear the buffer.

Mysql> exit
Bye
[Root @ sample ~] # Mysql-u root -hsample.centospub.com-p login Login login using the password as root
Enter password: Enter password here
Welcome to the MySQL monitor. Commands end with; or \ g. login confirm that you can log on with the password
Your MySQL connection id is 6 to server version: 4.1.20

Type 'help; 'or' \ H' forhelp. Type '\ C' to clear the buffer.

Mysql> exit MySQL Server
Bye


Once the password is set, you do not need to set the password after you log on again.

Directly knock

[Root @ sample ~] # Mysql-u root.


3. Install MySQL Workbench

Before that, make sure your computer has been installed

  • Microsoft. NET Framework 4 Client Profile
  • Visual C ++ Redistributable for Visual Studio 2013

After MySQL Workbench is successfully installed, you can connect to the ip address and port.
It should be noted that, if the firewall of the corresponding port in Linux is not closed, it cannot be connected.
The following is a Linux Command about the Firewall:
(1) It takes effect permanently and cannot be recovered after restart (not recommended)

Enable: chkconfig iptables on

Close: chkconfig iptables off

(2) takes effect immediately and recovers after restart (security risks exist)

Enable: service iptables start

Disable: service iptables stop


(3) Take 3306 as an example for a port.
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.