1. Confirm and Uninstall MySQL
Before you install MySQL, first verify that the system has MySQL installed, or uninstall it first.
[Email protected] ~]# Rpm-qa | grep MySQL//See if the system has MySQL installedmysql-libs-5.1. in-1. el6.x86_64//Query Results[Email protected] ~]# rpm-e--nodeps mysql-libs-5.1. in-1. el6.x86_64//Force Delete[Email protected] ~]# Rpm-qa | grep MySQL//MySQL has been successfully deleted, so I can't find MySQL.[[Email protected] ~] #备注: There are 2 types of MySQL delete modes: RPM-E Mysqlname//Normal Delete modeRPM-E--nodeps Mysqlname//forced Delete mode, which can be forcibly deleted if the normal delete mode prompts for a dependent file
2. mysql Installation
Install MySQL on Linux, there are a variety of installation methods, usually to the MySQL official website download (http://dev.mysql.com/downloads/mysql/5.6.html#downloads) and installed. Another convenient way is to install MySQL through yum.
[email protected] mysql]# Yum List | grep mysql // view available for installation of MySQL version // install MySQL server and client // to view the version number after installation
3. Configure MySQL
Start the MySQL service
[[Email protected] mysql]# service MySQL start // start MySQL services Note: Turn off the MySQL services: service mysqld Stop restart MySQL services: Service mysqld Restart
View and configure boot automatically start MySQL
[Email protected] mysql]# Chkconfig--list | grep mysqld//Check to see if MySQL is powered on from bootMysqld0: Close1: Close2: Close3: Close4: Close5: Close6: Close//mysql boot does not start[Email protected] mysql]# chkconfig mysqld on//Configuring MySQL Boot boot[Email protected] mysql]# Chkconfig--list |grep mysqldmysqld0: Close1: Close2: Enable3: Enable4: Enable5: Enable6: Close
After the installation of MySQL only one user root, and at this time the root password is empty, security needs to create a password for root
[Email protected] mysql]# mysqladmin-u root password'Tom' //Create a password for root for Tom[Email protected] mysql]# mysqladmin-uroot-ptom password'Root' //Change Root's secret to root[Email protected] mysql]# Mysql-uroot-proot//Connect to MySQLWelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is AServer Version:5.1. theSource Distributioncopyright (c) -, -, Oracle and/or its affiliates. All rights reserved. Oracle isA registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h' forHelp. Type'\c'To clear the current input statement.mysql>MySQL> show databases;//Show All Databases+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Test |+--------------------+3Rowsinch Set(0.00Sec
4. Main configuration file of MySQL database
1> /ETC/MY.CNF is the main configuration file for MySQL
[Email protected] mysql]# cat/etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var /lib/mysql/Mysql.sockuser=mysql# disabling symbolic is recommended to prevent Assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/ Mysqld.logpid-file=/var/run/mysqld/mysqld.pid
2> /var/lib/mysql is the MySQL database storage location
[email protected] mysql]# pwd/var/lib/Mysql[[email protected] mysql]# ll total dosage20488-RW-RW----.1MySQL MySQL10485760July - +: -ibdata1-RW-RW----.1MySQL MySQL5242880July - +: -Ib_logfile0-RW-RW----.1MySQL MySQL5242880July - -: +ib_logfile1drwx------.2MySQL MySQL4096July - -: + MySQL //database MySQL and test is the default database after installing MySQLSrwxrwxrwx.1MySQL MySQL0July - +: -mysql.sockdrwx------.2MySQL MySQL4096July - -: + Test //database MySQL and test is the default database after installing MySQL
3> /var/log is the MySQL data inventory log output storage location
[email protected] log]# pwd/var/Log[[email protected] log]# lsanaconda.ifcfg.log audit dracut.log secureanaconda.log Boot . Log Lastlog Secure-20150713anaconda.program.log btmp maillog spooleranaconda.storage.log cron Maillog-20150713spooler-20150713Anaconda.syslog Cron-20150713messages Tallyloganaconda.xlog DMESG messages-20150713wtmpanaconda.yum.log dmesg.old mysqld.log yum.log
4> View the port of the MySQL database (default port: 3306)
[Email protected] log]# NETSTAT-ANP | grep mysqltcp 0 0 0.0. 0.0:3306 0.0. 0.0:* LISTEN 1769/Mysqldunix 2 [ACC] STREAM LISTENING 16929 1769/mysqld /var/lib/mysql/mysql.sock
Installing MySQL in a Linux environment