Uninstall the original MySQL
Because MySQL database is very popular on Linux, so the mainstream Linux version of the current download basically integrates the MySQL database inside, we can use the following command to see if the MySQL database is installed on our operating system
grep mysql//This command will check if the MySQL database is already installed on the operating system
If there is, we can unload it by RPM-E command or rpm-e--nodeps command.
[[Email protected] ~]# RPM- normal Delete mode Brute force Delete mode, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly deleted
After the deletion we can pass Rpm-qa | grep mysql command to see if MySQL has been uninstalled successfully!!
Installation of MySQL via Yum
I am using yum to perform MySQL database installation, first we can enter Yum List | grep mysql command to view the downloadable version of the MySQL database available on Yum:
Yum grep MySQL
Then we can install the MySQL mysql-server mysql-devel by entering the yum install-y mysql-server mysql mysql-devel command ( Note: When we installed MySQL, we did not install the MySQL client, which is equivalent to installing the MySQL database, we also need to install the Mysql-server server .
Note: Mysql-deve is used for the C language Development interface and can not be installed
Yum Install
MySQL database initialization and related configurationService mysqld the start command to start our MySQL service.
Note : If we are starting the MySQL service for the first time, the MySQL server will first initialize the configuration, such as:
[[Email protected] ~service mysqld start[[email protected] ~Service mysqld Restart
When we use MySQL database, we have to start the Mysqld service first, we can check the MySQL service is not started automatically by chkconfig--list | grep mysqld command, such as:
grep mysqldmysqld 0: Off 1: Off 2: Off 3: Off 4: Off 5: Off 6: Off
We found that the MYSQLD service did not start automatically, and of course we can set it to boot up with the chkconfig mysqld on command, so you don't have to start it manually every time.
[[Email protected] ~grep mysqlmysqld 0: Off 1: Off 2 : Enable 3: Enable 4: Enable 5: Enable 6: Off
MySQL database after installation will only have a root administrator account, but at this time the root account has not set a password for it, the first time the MySQL service started, the database will be some initialization work, in the output of a large string of information, we see a line of information:
/usr/bin/mysqladmin-u root password ' New-password ' //Set the password for the root account
So we can use this command to set the password for our root account ( Note : This root account is the root account of MySQL, not the root account of Linux )
mysqladmin-u root Password ' Root '//Use this command to set the root account password to root
At this point we can log in to our MySQL database via the mysql-u root-p command.
V. Major configuration files for MySQL database
1./etc/my.cnf This is the main configuration file for MySQL
We can take a look at some information about this file
LScat my.cnf [mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/ Mysql.sockuser=mysql# Disabling symbolic-links are recommended to prevent assorted security Riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file =/var/run/mysqld/mysqld.pid
2. Storage location of database files for/var/lib/mysql MySQL Database
The database files for our MySQL database are usually stored in the/ver/lib/mysql directory.
[Email protected] ~]# cd/var/lib/mysql/[email protected] mysql]#ls-L Total Dosage20488-RW-RW----.1MySQL MySQL10485760April6 A: onibdata1-RW-RW----.1MySQL MySQL5242880April6 A: onIb_logfile0-RW-RW----.1MySQL MySQL5242880April6 +: -ib_logfile1drwx------.2MySQL MySQL4096April6 +: - MySQL//These two are the default two database file srwxrwxrwx when the MySQL database is installed .1MySQL MySQL0April6 A: onmysql.sockdrwx------.2MySQL MySQL4096April6 +: - Test //These two are the default two database files when the MySQL database is installed
We can create a database ourselves to verify where the database files are stored
Create a database of our own:MySQL>CREATE DATABASE Xiaoluo; Query OK,1Row affected (0.00sec) [Email protected] mysql]#ls-L Total Dosage20492-RW-RW----.1MySQL MySQL10485760April6 A: onibdata1-RW-RW----.1MySQL MySQL5242880April6 A: onIb_logfile0-RW-RW----.1MySQL MySQL5242880April6 +: -ib_logfile1drwx------.2MySQL MySQL4096April6 +: -mysqlsrwxrwxrwx.1MySQL MySQL0April6 A: onmysql.sockdrwx------.2MySQL MySQL4096April6 +: -testdrwx------.2MySQL MySQL4096April6 A: the Xiaoluo//This is the Xiaoluo database we just created [[email protected] mysql]# CD Xiaoluo/[email protected] xiaoluo]#lsdb.opt
3./var/log MySQL database log output storage location
Some of our MySQL database's log output is stored in the/var/log directory
[ Email protected] xiaoluo]# CD [[email protected]~]# cd/var/Log[[email protected] log]#lsAmanda Cron Maillog-20130331spice-Vdagent.loganaconda.ifcfg.log Cron-20130331Mcelog spooleranaconda.log cups messages spooler-20130331anaconda.program.log dirsrv Messages-20130331sssdanaconda.storage.log dmesg mysqld.log tallyloganaconda.syslog dmesg.old NT Pstats tomcat6anaconda.xlog dracut.log Piranha Wpa_supplicant.loganaconda.Yum. log GDM pm-powersave.log wtmpaudit httpd PPP Xorg.0. Logboot.log ibacm.log prelink Xorg.0. log.oldbtmp lastlog sa Xorg.1. Logbtmp-20130401Libvirt Samba Xorg.2. Logcluster Luci Secure Xorg.9. Logconsolekit Maillog Secure-20130331 Yum. log
Import Database:
Mysql-p Landing, and then Source/xx/xx.sql can
Remote IP Authorization Login:
Mysql> Grant all privileges on * * to ' root ' @ ' 219.141.190.16 ' identified by ' hello54987663 '
;
Query OK, 0 rows affected (0.02 sec)
Mysql> Flush Privileges
;
Query OK, 0 rows Affected (0.00 sec)