Linux installation mysql database tutorial

1 System conventions Installation file download directory: /data/software Mysql directory Installation location: /usr/local/mysql Database storage location: /data/mysql Log storage location: /data/log/mysql

2 Download mysql in the official website: http://dev.mysql.com/downloads/mysql/ , select the following version of mysql to download:

img

Perform the following naming: #mkdir /data/software #cd /data/software

--Download the installation package

--Recommendation: Use Thunder download on windows, the speed is very fast (mine is 1M/s), and then use the tool (Xftp) to upload to the /data/software directory; #wget http://dev.mysql.com/ get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

3 Unzip the compressed package to the target location

#cd /data/software

- Unzip the compressed package

#tar -xzvf /data/software/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

- Move and modify the file name

#mv /data/software/mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql

4 Create a data warehouse directory

--/data/mysql Data Warehouse Directory# mkdir /data/mysql
#ls /data/

img

* 5 Create new mysql users, groups and directories* # --- Create a new msyql group# useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql --- New msyql users are prohibited from logging in to the shell

6 Change the owner of the directory

#cd /usr/local/mysql #pwd #chown -R mysql . #chgrp -R mysql .

img

#chown -R mysql /data/mysql

* 7 configuration parameters * # bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

img

Here you need to pay attention to record the generated temporary password, as at the end of the above: YLi>7ecpe;YP #bin/mysql_ssl_rsa_setup --datadir=/data/mysql

img

8 modify the system configuration file

#cd /usr/local/mysql/support-files

img

# cp my-default.cnf /etc/my.cnf # cp mysql.server /etc/init.d/mysql

# vim /etc/init.d/mysql

Modify the following:

img

9 start mysql

# /etc/init.d/mysql start

--Login

# mysql -hlocalhost -uroot -p

  --If it appears: -bash: mysql: command not found

  - Just execute: # ln -s /usr/local/mysql/bin/mysql /usr/bin - No need to execute if it does not appear

--Enter the temporary password generated in step 6

--change Password

mysql> set password=password('root');

--Set the host address of the root account (remote connection only after modification)

mysql>grant all privileges on . to 'root'@'%' identified by 'root'; mysql>flush privileges;

--View table

mysql> use mysql; mysql> select host,user from user;

--Here you can use the remote connection test;

img

If you are prompted that you cannot connect successfully, you may need to add the port that needs to be monitored

/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

10Add system path # vim /etc/profile Add: export PATH=/usr/local/mysql/bin:$PATH as follows:

img

# source /etc/profile

* 11 Configure mysql to start automatically* # chmod 755 /etc/init.d/mysql # chkconfig --add mysql # chkconfig --level 345 mysql on

The above is the installation tutorial of Mysql 5.7.13 in the linux environment, I hope it will be helpful to everyone's study.

supplement:

-Exit the mysql command window

#exit

--View mysql status

#service mysql status

--Stop mysql

#service mysql stop

-Start mysql

#service mysql start

Attached my.cnf (this is a configuration file for configuring mysql, you can leave it alone for the time being, if you want to delve into it, you can Baidu or Google "mysql my.cnf configuration details")

/etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # * DO NOT EDIT THIS FILE. It's a template which will be copied to the # * default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 10G

# Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. log_bin character-set-server=utf8 collation-server=utf8_bin init-connect='SET NAMES utf8' # These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /export/mysql/var port = 3306 server_id = 22206 socket = /export/mysql/mysql.sock binlog_format = statement # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M log_bin_trust_function_creators = on sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

lower_case_table_names=1

The above is the Linux-related knowledge shared by Liangxu Tutorial Network for all friends.

Guess you like

Origin blog.csdn.net/manongxianfeng/article/details/113055408