MySQL is a small database management system that many people are very familiar with. its database performance is good, so it has won the favor of many users. This article mainly explains in detail the FAQs and answers to MySQL compiled on CU.
MySQLIt is a small database management system that many people are very familiar with. MySQL database performance is good, so it has won the favor of many users. In this article, we will explain in detail how to sort out the CUs.
MySQLI believe that through the following learning, you will be able to master the knowledge of MySQL.
Q: How to install LAMP (Linux + Apache + MySQL + PHP)
A: [url] http://www.freelamp.com/1003235699/index_html#/url]
Q: How to install mysql using rpm
A: first download the appropriate rpm package, such as downloading the file MySQL-5.0.15-0.i386.rpm
Use the following method to install:
# Rpm-ivhuMySQL-5.0.15-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-ivhuMySQL-devel-5.0.15-0.i386.rpm
# Rpm-ivhuMySQL-client-5.0.15-0.i386.rpm
Q: How to install a compiled mysql binary package
A: 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
# 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/database/my. cnf.
Q: How to compile mysql
A: Take redhat linux 9.0 as an example:
Download file 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-cycler \
-- With-mysqld-ldflags =-all-static -- localstatedir =/usr/local/mysql/data \
-- With-unix-socket-path =/tmp/mysql. sock -- enable-cycler \
-- With-charset = complex -- with-low-memory -- with-mit-threads
# Make
# Make install
# Groupadd mysql
# Useradd-g 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/database/my. cnf.
Q: How to log on to MySQL
A: log on using the client tool provided by mysql.
# PATH_TO_MYSQL/bin/mysql-uuser-ppassword dateabase
Q: How can I modify the root password of MySQL?
A: If MySQL is running, killall-TERM mysqld is first killed.
Start MySQL: PATH_TO_MYSQL/bin/mysqld -- skip-grant-tables &
You can access MySQL without a password.
Then
Mysql> use mysql
Mysql> update user set password = password ("new_pass") where user = "root ";
Mysql> flush privileges;
Kill MySQL again and start MySQL in a normal way
Note: Many new users do not use password = password ("..."), but directly use password = "...", so it is difficult to change the password.
Q: Why can't I log on when mysqld is up? the error "/var/lib/mysql. sock" does not exist
A: 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 the IP address and connect to mysql using tcp instead of local sock.
# 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
Q: How to change the mysql User password?
A: There are roughly two methods:
1,
Mysql> mysql-uroot-pxxx mysql
Mysql> update user set password = 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.
Q: How to add a mysql User
A: 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, you can also query, insert, modify, and delete the database mydb (localhost refers to the local host, that is, the host where the MYSQL database is located), so that the user knows the password of test2, he cannot access the database directly from the internet, but can only access the database through the web pages on the MYSQL host.
Mysql> grant select, insert, update, delete on mydb. * to test2 @ localhost identified by "abc ";
If you do not want test2 to have a password, you can run another command to remove the password.
Mysql> grant select, insert, update, delete on mydb. * to test2 @ localhost identified "";
In addition, you can insert a new record to the user table directly.
Q: How can I check the mysql database?
A: mysql> show databases;
The preceding section provides examples of MySQL common problems and solutions on the CU. of course, this section only summarizes some of them, more needs to be carefully discovered in your daily work, and finally hope that the content mentioned above will help you.