mysql note 1

lesson 1 

[root@xiaoluo ~]# rpm -qa | grep mysql // This command will check whether the mysql database has been installed on the operating system

[root@xiaoluo ~]# rpm -e mysql // Normal delete mode

[root@xiaoluo ~]# rpm -e --nodeps mysql // Forcibly delete mode, if you use the above command to delete other files that are dependent on it, you can use this command to delete it forcefully

I use yum to install the mysql database. First, we can enter the yum list | grep mysql command to view the downloadable version of the mysql database provided on yum:

 

[root@xiaoluo ~]#

 

 

centos reports an error in yum install: Another app is currently holding the yum lock solution

 

centos reported an error in yum install: Another app is currently holding the yum lock. This problem may be a problem that many novices often encounter. I have been asked before, including myself when I was just learning centos.

 

Another app is currently holding the yum lock, which obviously means that another app is using yum and is locked by being occupied, so what should I do, just end it.

 

You can force the yum process to shut down:

 

# rm -f /var/run/yum.pid

 

Then you can use yum. OK, very simple.

 

It seems that there is no mysql-sever file when mysql is installed normally in the yum source of entOS 7, you need to download it from the official website

 

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

# rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

MySQL comes with multiple sample parameter files to replace the actual parameter files. If the installation method is rpm package under Linux, the built-in parameter files will be placed under /usr/share/mysql

#pwd

ls *.cnf

 

Under linux, you can take the following command to view the status of the Mysql service:

netsat-nlp

 

start the service

service mysql start

service mysql restart

service mysql stop 

If --console is not added, the startup and shutdown information will not be displayed on the interface, but will be recorded in the data directory under the installation directory. The file name is generally hostname.err. You can view the console information of MySQL through this file.

 

When we use the mysql database, we have to start the mysqld service first. We can check whether the mysql service is automatically started at boot through the chkconfig --list | grep mysqld command, such as:

[root@xiaoluo ~]# chkconfig --list | grep mysqld

mysqld 0:shutdown 1:shutdown 2:shutdown 3:shutdown 4:shutdown 5:shutdown 6:shutdown

 

We found that the mysqld service does not start automatically at boot. Of course, we can set it to start at boot through the chkconfig mysqld on command, so that we don't have to manually start it every time.

[root@xiaoluo ~]# chkconfig mysqld on

[root@xiaoluo ~]# chkconfig --list | grep mysql

mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off

 

So we can use this command to set a password for our root account (note: this root account is the root account of mysql, not the root account of Linux)

[root@xiaoluo ~]# mysqladmin -u root password 'root' // Use this command to set the password for the root account to root

 

Five, the main configuration file of the mysql database

 

1./etc/my.cnf This is the main configuration file of mysql

 

We can look at some information about this file

 

copy code

[root@xiaoluo etc]# ls my.cnf 

my.cnf

 

[root@xiaoluo etc]# cat 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

copy code

2. /var/lib/mysql The database file storage location of the mysql database

 

The database files of our mysql database are usually stored in the directory /ver/lib/mysql

 

 

 

copy code

[root@xiaoluo ~]# cd /var/lib/mysql/

[root@xiaoluo mysql]# ls -l

Total usage 20488

-rw-rw----. 1 mysql mysql 10485760 4月   6 22:01 ibdata1

-rw-rw ----. 1 mysql mysql 5242880 April 6 22:01 ib_logfile0

-rw-rw----. 1 mysql mysql  5242880 4月   6 21:59 ib_logfile1

drwx------. 2 mysql mysql 4096 April 6 21:59 mysql // These two are the default two database files when the mysql database is installed

srwxrwxrwx. 1 mysql mysql 0 April 6 22:01 mysql.sock

drwx------. 2 mysql mysql 4096 April 6 21:59 test // These two are the default two database files when the mysql database is installed

copy code

 

 

We can create a database ourselves to verify the storage location of the database file

 

 

 

copy code

Create a database of our own:

mysql> create database xiaoluo;

Query OK, 1 row affected (0.00 sec)

 

[root@xiaoluo mysql]# ls -l

Total usage 20492

-rw-rw----. 1 mysql mysql 10485760 4月   6 22:01 ibdata1

-rw-rw ----. 1 mysql mysql 5242880 April 6 22:01 ib_logfile0

-rw-rw----. 1 mysql mysql  5242880 4月   6 21:59 ib_logfile1

drwx ------. 2 mysql mysql 4096 April 6 21:59 mysql

srwxrwxrwx. 1 mysql mysql 0 April 6 22:01 mysql.sock

drwx ------. 2 mysql mysql 4096 April 6 21:59 test

drwx------. 2 mysql mysql 4096 April 6 22:15 xiaoluo // This is the xiaoluo database we just created

[root@xiaoluo mysql]# cd xiaoluo/

[root@xiaoluo xiaoluo]# ls

db.opt

copy code

3. /var/log mysql database log output storage location

 

Some log outputs of our mysql database are stored in the /var/log directory

 

copy code

[root@xiaoluo xiaoluo]# cd 

[root@xiaoluo ~]# cd /var/log

[root@xiaoluo log]# ls

amanda                cron           maillog-20130331   spice-vdagent.log

anaconda.ifcfg.log    cron-20130331  mcelog             spooler

anaconda.log          cups           messages           spooler-20130331

anaconda.program.log  dirsrv         messages-20130331  sssd

anaconda.storage.log  dmesg          mysqld.log         tallylog

anaconda.syslog       dmesg.old      ntpstats           tomcat6

anaconda.xlog         dracut.log     piranha            wpa_supplicant.log

anaconda.yum.log      gdm            pm-powersave.log   wtmp

audit                 httpd          ppp                Xorg.0.log

boot.log              ibacm.log      prelink            Xorg.0.log.old

btmp                  lastlog        sa                 Xorg.1.log

btmp-20130401         libvirt        samba              Xorg.2.log

cluster               luci           secure             Xorg.9.log

ConsoleKit            maillog        secure-20130331    yum.log

 

The mysqld.log file is where we store some log information generated by our operations with the mysql database. By viewing the log file, we can get a lot of information from it

 

 

 

Because our mysql database can be accessed through the network, it is not a stand-alone database, and the protocol used is the tcp/ip protocol. We all know that the port number bound to the mysql database is 3306, so we can pass the netstat -anp command Let's see if the Linux system is listening on port 3306

 

Guess you like

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