Mysql installation and initial configuration
The first version of the Mysql database was released on the Linux system
View the mysql installation package:
] # rpm-qa | grep mysql
Mysql-libs-5.1.73-8.el6_8.x86_64
Mysql-5.1.73-8.el6_8.x86_64
View the mysql packages available for yum:
] # yum list | grep mysql
Installation:
] # yum install-y mysql-server mysql mysql-deve
Uninstall:
] # rpm-e mysql
-- the nodesp option forces deletion
View the installed mysql:
] # rpm-qi mysql
Start the mysql service:
] # service mysqld start
When we use the mysql database, we have to start the mysqld service first. We can check whether the mysql service starts automatically with the command chkconfig-- list | grep mysqld:
] # chkconfig-- list | grep mysqld
Mysqld 0: close 1: close 2: close 3: close 4: close 5: close 6: close
Use the chkconfig mysqld on command to set it to boot:
# chkconfig mysqld on
Set the password for the mysql default root:
] # / usr/bin/mysqladmin-u root password 'testpwd'
Log in to mysql:
# mysql-uroot-paired testpwd'
View the database:
Mysql > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | test |
+-+
3 rows in set (0.00 sec)
Mysql main configuration file:
] # cat / etc/my.cnf
[mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
[mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
Mysql database file:
# ls / var/lib/mysql/
Ibdata1 ib_logfile0 ib_logfile1 mysql mysql.sock test
Create your own database to verify the location of the database file:
Mysql > create database simonwang
Query OK, 1 row affected (0.00 sec)
] # ls-l / var/lib/mysql/
The total dosage is 20492
-rw-rw---- 1 mysql mysql 10485760 July 25 22:19 ibdata1
-rw-rw---- 1 mysql mysql 5242880 July 25 22:19 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 July 25 22:19 ib_logfile1
Drwx- 2 mysql mysql 4096 July 25 22:19 mysql
Srwxrwxrwx 1 mysql mysql 0 July 25 22:19 mysql.sock
Drwx- 2 mysql mysql 4096 July 25 22:32 simonwang
Drwx- 2 mysql mysql 4096 July 25 22:19 test
Mysql log output:
] # cat / var/log/mysqld.log
Mysql uses the tcpip protocol to see if it is listening on port 3306:
] # netstat-anp | grep 3306
Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN 1402/mysqld
Or check to see if 3006 is listening:
] # ss-tnl | grep 3306
LISTEN 0 50 *: 3306 *: *