Mysql is the most popular database system in linux. Today we will introduce the installation and simple operations of mysql!
Groupadd mysql // create a mysql user group
Useradd-g mysql // create a mysql account
Tar-zxvf mysql-x.x.xx.tar.gz // decompress mysql
Cd mysql-5.0.45 // enter the decompressed mysql directory
./Configure-prefix =/usr/local/mysql-with-charset = utf8-with-collation = utf8_general_ci-with-extra-charsets = latin1 // set parameters
Make
Make install // start Installation
Cp support-files/my-medium.cnf/etc/my. cnf // copy the my-medium.cnf file to the/etc/directory and rename it to my. cnf
Open the my. cnf file in the editor, find the log-bin = mysql-bin line, and comment it out.
: # Log-bin = mysql-bin
Cd/usr/local/mysql // enter the mysql directory
Bin/mysql_install_db -- user = mysql
Chown-R root. // Set directory permission attributes
Chown-R mysql/usr/local/mysql/var
Chgrp-R mysql
Bin/mysqld_safe -- user = mysql & // start mysql
Open the/etc/rc. local file in the editor and add/usr/local/mysql/bin/mysqld_safe-user = mysql &
Restart and enter mysql. If yes, the startup is successful!
----------- Common mysql commands --------
Mysql-uroot-p // log on to the mysql server and use the user name as the root user.
Mysqladmin-uroot-p password 1234 // 1234 is the new password
Create database mydb; // create a database named mydb
Drop database mydb // delete a database named mydb
Show databases // view the database
Desc func // view the detailed structure of the data table
---------- Key and common database maintenance operations ----
Mysqldump-uroot-p-all-database>/Users/venmos/backup. SQL // back up all databases to the backup. SQL file in the/Users/venmos/directory.
Mysqldump-uroot-p mydb>/Users/venmos/backup. SQL // back up the backup. SQL file in the/Users/venmos/directory of the mydb Database
Use/Users/venmos/backup. SQL // import the backup. sqldatabase IN THE/Users/venmos/directory
The above is about mysql installation and simple operation methods, and I hope it will be useful to you!