First, check whether the rpm-Qa | grep MySQL has been installed. Check both of them.
Rpm-Qa | grep MySQL
If the installation is detachable, run the rpm-e ****** command to uninstall the customer service and server.
1. Download the MySQL Installation File
The following two files are required to install MYSQL:
MySQL-server-5.0.16-0.i386.rpm
MySQL-client-5.0.16-0.i386.rpm
For: http://dev.mysql.com/downloads/mysql/5.0.html
Ii. Install MySQL
The RPM file is a software installation package developed by Red Hat. RPM frees Linux from complicated procedures when installing software packages. The frequently used parameter of this command during installation is-IVH, where I indicates that the specified RMP package will be installed, and V indicates the detailed information during installation, h indicates that the "#" symbol appears during the installation to display the current installation process. This symbol will not stop until the installation is complete.
1) Create the directory mkdir-P usr/local/MySQL before installation.
CD to enter the Directory and upload the installation package to the/usr/local/MySQL directory.
2) install the server
[Root @ bogon local] # cd/user/local/MySQL
[Root @ bogon local] # rpm-IVH MySQL-server-5.0.16-0.i386.rpm
Run netstat to check whether the MySQL port is opened. If yes, the service is started and the installation is successful. The default MySQL port is 3306.
[Root @ bogon local] # netstat-Nat
3) install the client
[Root @ bogon local] # rpm-IVH MySQL-client-5.0.16-0.i386.rpm
Test whether MySQL is successfully logged on. The default MySQL user is root. Because there is no password at first, you only need to enter MySQL for the first time. [Note: This root user is not a Linux system, and the initial MySQL management account is root without a password.]
[Root @ bogon local] # MySQL
The prompt "mysql>" appears. Congratulations! The installation is successful!
The logon format after the password is added is as follows:
[Root @ bogon local] # mysql-u root-P
Enter Password: (enter the password)
-U is followed by the user name.-P requires the password. Press enter and enter the password at the Enter password.
Note: This MySQL file is located in the/usr/bin directory. It is not a file with the Startup file/etc/init. d/MySQL described later.
4) verify whether the installation is successful:
Rpm-Qa | grep MySQL
5) change the password
[Root @ bogon local] #/Usr/bin/mysqladmin-u Root Password '123'
6) Assign permissions to the host you are connected
> MySQL grant select, insert, update, delete on *. * To root@xxx.xxx.x.xx identified by '20140901'; // XXX. XXX. X. XX is your IP address
7) change the default MySQL Character Set
# Cp my-medium.cnf/etc/My. CNF
Add default-character-set = utf8 under [client]
Add default-character-set = utf8 under [mysqld]
Iii. Important MySQL Directories
1. Database directory/var/lib/MySQL/
2. Configuration File/usr/share/MySQL (MySQL. server command and configuration file)
3. Related commands/usr/bin (mysqladmin mysqldump and other commands)
4. Start the script/etc/rc. d/init. d/(the directory for starting the script file MySQL)
4. Start and Stop
1. Start
After MySQL is installed, run the following command to start MySql in the/etc/init. d directory.
[Root @ bogon init. d] #/etc/init. d/MySQL start
Method 2: [root @ bogon init. d] #/usr/share/MySQL. Server start
2. Stop
[Root @ bogon bin] #/usr/bin/mysqladmin-u root-P Shutdown
5. Auto Start
Add/usr/share/MySQL. Server start at the end of the RC. Local file.
[Root @ bogon init. d] # vi/etc/rc. d/init. d/rc. Local
/Usr/share/MySQL. Server start
Vi. Problems Encountered during installation
1. the prompt conflicts with file from package is displayed when MySQL-server is installed in Linux.
The cause is a package conflict! To solve this problem, first remove the conflicting libs package and install it.
Solution: Yum-y remove mysql-libs-5.1.52 *-y means you don't have to ask whether to remove
VII. Common MySQL operations
After MySQL is installed, two accounts are generated by default: one is root, and no password is set. You can log on to MySQL from the local machine; the other is an anonymous account, with no account name or password. you can log on from the local machine, all connections without user names are assumed to be this account.
Note: Each Command in MySQL must end with a semicolon.
1. display the database
Mysql> show database;
2. display tables in the database
Mysql> use MySQL; (open the database to open each database)
Mysql> show tables;
3. display the data table structure
Mysql> describe table name;
4. Display records in the table
Mysql> select * from table name;
5. Create a database
Mysql> Create Database database name;
6. Create a table
Mysql> Use Database Name;
Mysql> Create Table Name (field setting list );
7. Add records
Mysql> insert into Table Name (column name) values (....);
8. Modify records
Mysql> Update ...;
9. delete records
Mysql> Delete from table name where ...;
10. Delete databases and tables
Mysql> drop database database name;
Mysql> drop table name;
11. delete an anonymous account:
Mysql> Delete from user where user = '';
12. delete an account with a blank password:
Mysql> Delete from user where Password = '';
13. delete accounts that allow non-localhost login:
Mysql> Delete from user where host <> 'localhost ';
14. Make the command take effect
Mysql> flush privileges;
15. Exit MySQL
Mysql> exit;
16. mysql> grant all privileges on *. * to root @"%"Identified"Root"; // Add the remote connection capability to the root user.
If remote connection is not available, disable the firewall.
[Root @ bogon ~]#/Etc/rc. d/init. d/iptables stop