The following articles mainly introduce the specific use of linux MySQL and the description of some important matters worth attention in the actual operations of linux MySQL, the following describes the specific usage of linux MySQL. I hope it will be helpful in your future studies.
Where is the MySQL Data Inventory (Chen Xu)
1. If the rpm package is used for installation, the directory name of the database should be in the/var/lib/MySQL directory.
2. If the source code is installed in/usr/local/MySQL, use the database name as the directory name in/usr/local/MySQL/var.
5002 export and import data from linux MySQL (Chen Xu)
Export Database
MySQLdump Database Name> file name
Import Database
MySQLadmin create database name
MySQL database name <file name
5003 forget the root password of MySQL (Chen Xu)
- # service MySQL stop
- # MySQLd_safe --skip-grant-tables &
- # MySQLadmin -u user password 'newpassword''
- # MySQLadmin flush-privileges
5004 quick installation of php/MySQL (Chen Xu)
Make sure that all rpm packages starting with MySQL and php-MySQL are found from the installation disc using the system's built-in apache, and then run # rpm-ivh MySQL *. rpm php-MySQL *. rpm; MySQL_install_db; service MySQL start
5005 modify the root password of linux MySQL (Chen Xu, yejr)
There are roughly two methods:
1. MySQL> MySQL-uroot-pxxx MySQL
- MySQL>update user set passwordpassword=password('new_password') where user='user';
- MySQL>flush privileges;
2. Format: MySQLadmin-u username-p old password New password
# MySQLadmin-uroot-password ab12
Note: because the root account does not have a password at the beginning, the old-p password can be omitted.
5006 how to install MySQL (yejr) using rpm)
First download the appropriate rpm package, such as downloading the file MySQL-5.0.19-0.i386.rpm
Use the following method to install:
# Rpm-ivhuMySQL-5.0.19-0.i386.rpm
Generally, after this rpm package is installed, only the MySQLd service functions are available. Other related client programs and Development Kits need to be installed separately.
- #rpm -ivhU MySQL-devel-5.0.19-0.i386.rpm
- #rpm -ivhU MySQL-client-5.0.19-0.i386.rpm
5007 how to install the compiled MySQL Binary Package (yejr)
First download the appropriate binary package, such as downloading the file MySQL-standard-4.1.13-pc-linux-gnu-i686.tar.gz
- #groupadd MySQL
- #useradd -g MySQL MySQL
- #cd /usr/local
- #tar zxf MySQL-standard-4.1.13-pc-linux-gnu-i686.tar.gz
- #ln -s MySQL-standard-4.1.13-pc-linux-gnu-i686 MySQL
- #cd MySQL
- #scripts/MySQL_install_db --user=MySQL
- #chgrp -R MySQL *
- #bin/MySQLd_safe --user=MySQL &
You can add related parameters by creating/etc/my. cnf or/usr/local/MySQL/data/my. cnf.
5008 how to compile MySQL (yejr) by yourself)
Take redhat linux 9.0 as an example:
Download file linux MySQL-4.1.13.tar.gz
- #tar zxf MySQL-4.1.13.tar.gz
- #cd MySQL-4.1.13
- #./configure --prefix=/usr/local/MySQL --enable-assembler \
- --with-MySQLd-ldflags=-all-static --localstatedir=/usr/local/MySQL/data \
- --with-unix-socket-path=/tmp/MySQL.sock --enable-assembler \
- --with-charset=complex --with-low-memory --with-mit-threads
- #make
- #make install
- #groupadd MySQL
- #useradd -g MySQL MySQL
- #chgrp -R MySQL /usr/local/MySQL/
- #/usr/local/MySQL/bin/MySQLd_safe --user=MySQL &
You can add related parameters by creating/etc/my. cnf or/usr/local/MySQL/data/my. cnf.
5009 how to log on to MySQL (yejr)
Use the client tool provided by MySQL to log on
# PATH_TO_MySQL/bin/MySQL-uuser-ppassword dateabase
5010 when MySQLd is up, but cannot log on, the prompt "/var/lib/MySQL. sock" does not exist (yejr)
In most cases, because your MySQL is installed in rpm mode, it will automatically find the/var/lib/MySQL. sock file,
Log on to MySQL through a unix socket.
Common solutions:
1. Create/modify the/etc/my. cnf file and add/modify at least one line.
[MySQL]
[Client]
Socket =/tmp/MySQL. sock
# Write the correct location of your MySQL. sock Here, usually either under/tmp/or under/var/lib/MySQL/
2. Specify an IP address and connect to MySQL using tcp instead of local sock.
# Linux MySQL-h127.0.0.1-uuser-ppassword
3. Add a connection for MySQL. sock. For example, if the actual MySQL. sock is under/tmp /,
# Ln-s/tmp/MySQL. sock/var/lib/MySQL. sock
5011 how to add a MySQL user (yejr)
Format: grant select on database. * to username @ login host identified by "password"
Example 1: Add a user named "test1" with the password "abc" so that the user can log on to any host and have the permission to query, insert, modify, and delete all databases. First, use the root user to connect to MySQL, and then type the following command:
MySQL> grant select, insert, update, delete on *. * to test1 @ "%" Identified by "abc ";
However, the User Added in Example 1 is very dangerous. If someone knows the password of test1, then he can log on to your MySQL database on any computer on the internet and do whatever he wants for your data. For the solution, see Example 2.
Example 2: Add a user named "test2" with the password "abc" so that the user can only log on to localhost and query, insert, modify, and delete the Database "mydb". localhost indicates the local host, that is, the host where the MySQL database is located). In this way, the user knows the password of test2 and cannot directly access the database from the internet, it can only be accessed through a web page on the linux MySQL host.