Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MySQL under CentOs

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to install MySQL under CentOs, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

1. Preparatory work

Linux installs the mysql service in two ways:

1) Source code installation, the advantage is that the installation package is relatively small, only more than ten M, the disadvantage is that the installation depends on many libraries, the installation and compilation time is long, and the installation steps are complex and easy to make mistakes.

2) using officially compiled binaries to install, the advantage is that the installation speed is fast, the installation steps are simple, and the disadvantage is that the installation package is very large, about 300m. Here's how linux installs mysql using an officially compiled binary package.

Mysql-5.6.17-linux-glibc2.5-i686.tar.gz (32-bit Linux)

Mysql-5.6.17-linux-glibc2.5-x86_64.tar.gz (64 bit Linux)

Linux system, either 32-bit or 64-bit

two。 Installation steps

1) download the mysql-compiled binary installation package from the mysql official website. On the download page Select Platform: select linux-generic, then pull to the bottom of the page. Download Linux-Generic (glibc 2.5) (x86, 64-bit) for 64-bit systems and Linux-Generic (glibc 2.5) (x86, 32-bit) for 32-bit systems.

2) decompress the 32-bit installation package:

Enter the directory where the installation package is located and execute the command: tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz

3) copy the extracted mysql directory to the local software directory of the system:

Execute the command: cp mysql-5.6.17-linux-glibc2.5-i686/usr/local/mysql-r

Note: do not add / at the end of the directory

Add system mysql groups and mysql users:

Execute commands: groupadd mysql and useradd-r-g mysql mysql

Install the database:

Enter the directory to install the mysql software: execute the command cd / usr/local/mysql

Change the current directory owner to mysql user: execute the command chown-R mysql:mysql. /

Install the database: execute the command. / scripts/mysql_install_db--user=mysql

Change the current directory owner to root user: execute the command chown-R root:root. /

Change the current data directory owner to mysql user: execute the command chown-R mysql:mysql data

At this point, the database is installed.

4) start mysql service and add boot startup mysql service:

Add boot boot: execute the command cp support-files/mysql.server/etc/init.d/mysql and put the startup script in the boot initialization directory

Start the mysql service: execute the command service mysql start

Execute command: ps-ef | when grep mysql sees the mysql service, it indicates that it started successfully, as shown in the figure.

Modify the root user password of mysql. The initial root password is empty:

Execute the command:. / bin/mysqladmin-u root password 'password'

Put the mysql client in the default path:

Ln-s / usr/local/mysql/bin/mysql / usr/local/bin/mysql

Note: it is recommended to use soft chain, do not directly package file copy, to facilitate the system to install multiple versions of mysql

3. Open a remote connection

By default, you cannot use the client to connect remotely. The help.docx provided by Aliyun contains the setting instructions, and the mysql password is stored by default.

Log in first: mysql-uroot-p

Enter password

Usemysql # Open mysql database

# setting host to% means that any ip can connect to mysql. Of course, you can also specify host as an ip

Update user set host='%' where user='root'and host='localhost'

Flushprivileges; # refresh the permissions table to make the configuration effective

Then we can connect to our mysql remotely.

If you want to close the remote connection and restore the default setting of mysql (local connection only), you can do the following:

Usemysql # Open mysql database

# setting host to localhost means you can only connect to mysql locally

Update user set host='localhost' whereuser='root'

Flushprivileges; # refresh the permissions table to make the configuration effective

Note: you can also add a remote connection user whose user name is jeesz, password is jeesz, and permission is% (which means any ip can connect). The command reference is as follows:

Grant all on *. * to 'jeesz'@'%' identifiedby' jeesz'

Flush privileges

Thank you for reading this article carefully. I hope the article "how to install MySQL under CentOs" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report