Linux system installation steps and screenshots of MySql

The original text comes from [Tingyun Technology Blog]: http://blog.tingyun.com/web/article/detail/1255

 The following is the record of my work, which introduces the installation process and installation screenshot of MySql using the official compiled binary file under the linux system. This installation method is fast and the installation steps are simple!

Friends who need it can install it according to the following steps, you can quickly install MySql, I hope it can help you :)!

1. Download the binary installation package of the linux version of mysql:

Address: http://dev.mysql.com/downloads/mysql/

Here I renamed the installation package to: tingyun-mysql-5.6.22.tar.gz

Note: You can not rename according to your needs

2. Unzip the installation package:

Unzip the installation package in the location to be installed: execute the command as follows:

cd /opt
tar –xPf tingyun-mysql-5.6.22.tar.gz

The screenshot is as follows:

1.jpg

3. Create the mysql installation directory and modify the directory permissions:

The execution command is as follows:

Create the mysql directory: mkdir mysql

Open the mysql directory: cd mysql

Create the data directory: mkdir data

Description: Because the mysql service process mysqld will access the data directory when it runs, create the data directory

Execute the following command in the mysql directory: used to set the owner of the directory to the mysql user:

chown mysql:mysql /opt/mysql –R

The screenshot is as follows:

2.jpg

4. Install mysql

Execute the installation command mysql_install_db in the mysql directory:

./scripts/mysql_install_db --user=mysql –datadir=/opt/mysql/data

The screenshot is as follows:

3.jpg

5. Start mysql

Enter the init.d directory and execute the command:

cd /etc/init.d/
mysqld restart

如果不想重新启动,那可以直接手动启动,执行如下命令:

service mysqld start

也可以直接在mysql目录下执行如下命令:

/etc/init.d/mysqld restart

截屏如下:

4.jpg

6、为mysql创建软链接

执行如下命令:

ln –s /opt/mysql/bin/mysql /user/bin

截屏如下:

5.jpg

7、修改mysql配置

执行如下命令进行编辑:

vim .bash_profile

说明:配置使用./mysql的目录(如bin目录里面使用 ./mysql)

(1)在bash_profile 文件的最下面写 

export PATH=$PATH:/usr/local/mysql/bin(你的安装bin目录)

执行:wq 命令进行保存退出

(2)执行source命令使系统配置生效:

source /.bash_profile

截屏如下:

6.jpg

8、安全配置向导

Mysql安装完毕后需要按照安全配置想到对mysql进行安全配置:

执行如下命令,对mysql的root用户进行安全配置:

mysql_secure_installation

设置新密码选择“Y”,并输入两次新密码(第二次作为确认密码)。

删除匿名用户,选择“Y”

截屏如下:

7.jpg

也可以通过如下方式,为root用户设置密码:

执行如下命令:

mysql –uroot –pnbs2o13

截屏如下:

8.jpg

查看mysql安装目录下内容

截屏如下:

9.jpg

9、mysql安装后测试:

(1)查看mysql是否已经启动:

使用如下三种命令中任何一种都可以:

netstat -tl | grep mysql
ps -aux | grep mysqld
netstat -lntup|grep 3306

屏幕中打印出mysql相关进程, 会看到如下类似内容:

tcp 0 0 *:mysql *:* LISTEN

说明mysql已经启动成功!

(2)要使用mysql,需要如下命令进入mysql:

mysql -u root -p

(3)查看版本:

select version();

So far, mysql has been installed and tested successfully, you can use it with confidence :)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326589571&siteId=291194637