Remote installation of MySQL under Linux

Source: Internet
Author: User

Xshell command Daquan: reference: 52037032

Find a file Find/-name mysql-5.5.60-linux-glibc2.12-i686.tar.gz

Enter a path cd/root

Deploying MySQL on a Linux remote server reprint: https://www.2cto.com/database/201803/727660.html

1. Pre-preparation

1.1 Required Software

Log on to the remote server tool: Xshell

File Transfer tool: Xftp

1.2 Shutting down the server firewall

Run the command to turn off the firewall

Systemctl Stop Firewalld.service

Run a command to turn off the firewall boot from boot

Systemctl Disable Firewalld.service

1.3 Installing VIM and Unzip

Yum Install-y vim Unzip
2. Port configuration

Open the 3306 port of the Linux server

3. Compile and install MySQL

3.1 Run the command to check if MySQL or MariaDB is present in the system.

Rpm-qa | grep Mysqlrpm-qa | grep mariadb

If present, execute the following command to delete

RPM-E software name    #注意: The software name here must contain the version information of the software, such as Rpm-e mariadb-libs-5.5.52-1.el7.x86_64. This command is typically used to uninstall success. RPM-E--nodeps software name   #卸载不成功时使用此命令强制卸载

3.2 Run the following command to install MySQL

Yum install-y libaio-*       #安装依赖 mkdir-p/usr/local/mysql     #创建mysql安装目录 cd/usr/local/src             #进入软件压缩包管理区域 wget https://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz                               # Download MySQL installation package tar-xzvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz online                              #在线解压mysql安装包mv mysql-5.7.17-linux-glibc2.5-x86_64/*/usr/local/mysql/                              #移动解压文件至mysql目录

3.3 Run the following command to set up the MySQL group and the user, and add the user to the group

Groupadd mysqluseradd-g mysql-s/sbin/nologin MySQL

Run the command to initialize the MySQL database

/usr/local/mysql/bin/mysqld--initialize-insecure--datadir=/usr/local/mysql/data/--user=mysql

3.4 Changing the properties of the MySQL installation directory

Chown-r Mysql:mysql/usr/local/mysql

3.5 Run the following command to set the boot from

CD/USR/LOCAL/MYSQL/SUPPORT-FILES/CP mysql.server  /etc/init.d/mysqldchmod +x/etc/init.d/mysqld             # Add Execute permissions Vim /etc/rc.d/rc.local

Add/etc/init.d/mysqld start in the rc.local file

(Press I to enter edit mode, press ESC to exit edit mode, press: Wq to save and exit)

3.6 Starting the MySQL database

/etc/init.d/mysqld start

3.7 Setting Environment variables

3.7.1

Run Vi/root/.bash_profile to open the file and press I to enter edit mode.

Change PATH to

Path= $PATH: $HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib.

Press the ESC key to exit edit mode, enter: Wq save and close the file.

Run Source/root/.bash_profile to re-execute the file

3.7.2

Modify the root user password for MySQL: After initialization, MySQL will be able to log in with a blank password, in order to ensure the security needs to modify the root user password of MySQL.

mysqladmin-u Root password Password

3.7.3

Test log in to the MySQL database.

Mysql-uroot-p         no spaces between password #-p and password

3.7.4

Remote Database Authorization

Grant all privileges the user name created by * to ("%" identified by "password";

  

3.8 Testing remote connections

Then the database is installed successfully, is not very simple.

Note: The root password setting is not there, you need to re-

Ways to change the root password

There's a pit: The new version of MySQL's user table's password field is changed to Authentication_string

Stop the MySQL service process first

service mysqld stop       

Then edit the MySQL configuration file my.cnf

vim /etc/my.cnf      

Find **[mysqld]** This module
Add a piece of code on the last side

skip-grant-tables   ##忽略mysql权限问题,直接登录      

Then Save: wq! exit
To start the MySQL service:

service mysqld start      

Go directly to MySQL database

mysql      

Use MySQL table, and then make changes to the root password of MySQL

mysql> use mysql; ##使用mysql数据库      Database changed      mysql> update user set authentication_string=password("121312321") where user="root";##更新密码 Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> flush privileges;##刷新权限 Query OK, 0 rows affected (0.00 sec) mysql> quit Bye 

Change the login verification of MySQL back

vi /etc/my.cnf       

Remove the skip-grant-tables** that was added to the paragraph in **[mysqld] earlier

Save and Exit VI.

Restart Mysqld

service mysqld start       Starting MySQL. SUCCESS!      

When you change your password, you will get an error when you use MySQL

Workaround:

  

Remote installation of MySQL under Linux

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.