[1] View mysql
ps -ef|grep mysql
root 17659 1 0 2011 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid
mysql 17719 17659 0 2011 ? 03:14:57 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
usr/bin/mysql Means: mysql Running Path
var/lib/mysql Means: mysql Storage Path of Database Files
usr/lib/mysql Means: mysql Installation Road
[2] Connect to the database
mysql -uroot[username] -p
Enter password:
[3] mysql service
service mysqld stop ; service mysqld start; After service restart, it may be out of order. tomcat needs to be restarted!!!
If there is no installation, prompt:
[root@localhost ~]# service mysqld start
mysqld:Unrecognized services
Check if the service has been added to linux (if installed, it will be prompted as follows)
[root@localhost ~]# chkconfig --list mysqld
mysqld 0:Close 1:Close 2:Close 3:Close 4:Close 5:Enable 6:Close
If there is no installation, prompt:
[root@localhost ~]# chkconfig --list mysqld Error reading information in mysqld service, no file or directory
Once you start the service, you can check whether the server is running or not.
[root@localhost ~]# ps -el | grep mysqld 4 S 0 1796 1 0 85 0 - 1513 wait ? 00:00:00 mysqld_safe 4 S 27 1856 1796 0 78 0 - 34055 - ? 00:00:00 mysqld [root@localhost ~]# If you see it, it means that the server is installed ~~
[4] Backup database
mysqldump basic grammar: mysqldump -u username -p dbname table1 table2 ...-> BackupName.sql Among them: The dbname parameter represents the name of the database. The table1 and table2 parameters indicate the name of the table that needs to be backed up, and if it is empty, the whole database will be backed up. BackupName.sql parameter table designs the name of the backup file, which can be preceded by an absolute path. Usually the database is divided into a file with the suffix sql. For example, backup cloudoa database to the current path: mysqldump -uroot -p cloudoa >./backup.sql
[5] Check and repair database tables
If the following prompt appears:
Table './hb_cloudoa/tb_xmpp_notice' is marked as crashed and should be repaired
Operation:
Login: mysqlcheck-u root-p hb_cloudoa Enter password: Then add the auto-repair parameter to repair automatically.
It's better to back up the database before repairing it (as shown in the fourth above):
mysqldump -u root -p hb_cloudoa > hb_cloudoa.sql
Enter password:
[Repair]
mysqlcheck -u root -p hb_cloudoa --auto-repair
Enter password:
[6] View File Installation Path
whereis mysql
[root@YCOffcie /]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/include/mysql /usr/local/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
[7] Query the path of the running file (folder address)
which mysql
[root@YCOffcie /]# which mysql
/usr/bin/mysql