Install MySql on CentOS and mysql on centos

Source: Internet
Author: User
Tags crc32

Install MySql on CentOS and mysql on centos
1. Download the MySQL Installation Package 1) http://dev.mysql.com/downloads/mysql/ open URL: Select Platform: Select Linux-Generic SelectLinux-Generic (glibc 2.5) (x86, 64-bit), RPM for download;Linux download: wget http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle.tar 2) after downloading decompress and put it in the installation folder: tar-xf MySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle.tarmv MySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle/usr/local/software/mv MySQL-5.6.22-1.linux_glibc2.5.x86_64.rpm-bundle mysql which is to use these two: MySQL database: MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpmMySQL client: MySQL-cl Ient-5.6.22-1.linux_glibc2.5.x86_64.rpm 3) installation environment: cat/etc/redhat-release CentOS release 6.4 (Final) II. MySql installation 1) 3) Check installation before installing MySQL, first, check whether a MySQL has been installed in CentOS. If it has been installed, uninstall it first. Otherwise, the installation of the new MySQL will fail. Rpm-qa | grep mysql -- check whether MySQL is installed before the system.

Mysql-libs-5.1.47-4.el6.i686 display results show that CentOS6.0 system comes with a MySQL, We need to delete this old version,RootThe user executes the following statement

Su-password:
Rpm-e -- nodeps mysql-libs-5.1.47-4.el6.i686
Switch to the "root" user first, and then execute the delete statement. After deletion, we can check again and find that the old MySQL version that comes with CentOS6.0 has been successfully deleted. After you delete the rpm of MySQL, You need to perform some scanning operations. There are two types of operations on the Internet. (Note: I have not used both of them here and found that there is no other residual MySQL information in the system .) First, use the following command to handle the problem. Rm-rf/var/lib/mysql * rm-rf/usr/share/mysql * Another aftercare solution:/etc/my in/var/lib/mysql after uninstallation. cnf will be renamed to my. cnf. rpmsave,/var/log/mysqld. log will be renamed to/var/log/mysqld. log. rpmsave. Delete it manually if you are sure it is useless. 2) install MySql Server rpm-ivh MySQL-server-5.6.22-1.linux_glibc2.5.x86_64.rpm
Preparing... ######################################## ### [100%]
1: mySQL-server ##################################### ###### [100%]
Warning: user mysql does not exist-using root
Warning: group mysql does not exist-using root
2014-08-10 22:43:44 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
22:43:44 23012 [Note] InnoDB: Using atomics to ref count buffer pool pages
22:43:44 23012 [Note] InnoDB: The InnoDB memory heap is disabled
22:43:44 23012 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
22:43:44 23012 [Note] InnoDB: Memory barrier is not used
22:43:44 23012 [Note] InnoDB: Compressed tables use zlib 1.2.3
22:43:44 23012 [Note] InnoDB: Using Linux native AIO
22:43:44 23012 [Note] InnoDB: Not using CPU crc32 instructions
22:43:44 23012 [Note] InnoDB: Initializing buffer pool, size = 128.0 M
22:43:44 23012 [Note] InnoDB: Completed initialization of buffer pool
22:43:45 23012 [Note] InnoDB: The first specified data file./ibdata1 did not exist: a new database to be created!
22:43:45 23012 [Note] InnoDB: Setting file./ibdata1 size to 12 MB
22:43:45 23012 [Note] InnoDB: Database physically writes the file full: wait...
22:43:45 23012 [Note] InnoDB: Setting log file./ib_logfile101 size to 48 MB
22:43:46 23012 [Note] InnoDB: Setting log file./ib_logfile1 size to 48 MB
22:43:46 23012 [Note] InnoDB: Renaming log file./ib_logfile101 to./ib_logfile0
22:43:46 23012 [Warning] InnoDB: New log files created, LSN = 45781
22:43:46 23012 [Note] InnoDB: Doublewrite buffer not found: creating new
22:43:46 23012 [Note] InnoDB: Doublewrite buffer created
22:43:46 23012 [Note] InnoDB: 128 rollback segment (s) are active.
22:43:46 23012 [Warning] InnoDB: Creating foreign key constraint system tables.
22:43:47 23012 [Note] InnoDB: Foreign key constraint system tables created
22:43:47 23012 [Note] InnoDB: Creating tablespace and datafile system tables.
22:43:47 23012 [Note] InnoDB: Tablespace and datafile system tables created.
22:43:47 23012 [Note] InnoDB: Waiting for purge to start
22:43:47 23012 [Note] InnoDB: 5.6.22 started; log sequence number 0
A random root password has been set. You will find it in '/root/. mysql_secret '.
22:43:48 23012 [Note] Binlog end
22:43:48 23012 [Note] InnoDB: FTS optimize thread exiting.
22:43:48 23012 [Note] InnoDB: Starting shutdown...
22:43:50 23012 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2014-08-10 22:43:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
22:43:50 23039 [Note] InnoDB: Using atomics to ref count buffer pool pages
22:43:50 23039 [Note] InnoDB: The InnoDB memory heap is disabled
22:43:50 23039 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
22:43:50 23039 [Note] InnoDB: Memory barrier is not used
22:43:50 23039 [Note] InnoDB: Compressed tables use zlib 1.2.3
22:43:50 23039 [Note] InnoDB: Using Linux native AIO
22:43:50 23039 [Note] InnoDB: Not using CPU crc32 instructions
22:43:50 23039 [Note] InnoDB: Initializing buffer pool, size = 128.0 M
22:43:50 23039 [Note] InnoDB: Completed initialization of buffer pool
22:43:50 23039 [Note] InnoDB: Highest supported file format is Barracuda.
22:43:50 23039 [Note] InnoDB: 128 rollback segment (s) are active.
22:43:50 23039 [Note] InnoDB: Waiting for purge to start
22:43:50 23039 [Note] InnoDB: 5.6.22 started; log sequence number 1625977
22:43:50 23039 [Note] Binlog end
22:43:50 23039 [Note] InnoDB: FTS optimize thread exiting.
22:43:50 23039 [Note] InnoDB: Starting shutdown...
22:43:52 23039 [Note] InnoDB: Shutdown completed; log sequence number 1625987

A random password has been set for the MySQL root USER!
You will find that password in '/root/. mysql_secret '.

You must change that password on your first connect,
No other statement but 'set password' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

/Usr/bin/mysql_secure_installation

Which will also give you the option of removing the test database.
This is stronugly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web

Http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as/usr/my. cnf and
Will be used by default by the server when you start it.
You may edit this file to change server settings

3) Check whether port 3306 of MySQL is enabled. 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 @ hadoop Mysql] # netstat-nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
Tcp 0 0 0.0.0.0: 50070 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 22 0.0.0.0: * LISTEN
Tcp 0 0 127.0.0.1: 631 0.0.0.0: * LISTEN
Tcp 0 0 127.0.0.1: 25 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 50010 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 50075 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 50020 0.0.0.0: * LISTEN
Tcp 0 0 192.168.128.129: 9000 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 50090 0.0.0.0: * LISTEN
Tcp 1 0 192.168.128.129: 35744 63.130.76.64: 80 CLOSE_WAIT
Tcp 0 0 192.168.128.129: 34847 192.168.128.129: 9000 ESTABLISHED
Tcp 0 0 192.168.128.129: 35770 192.168.128.129: 9000 TIME_WAIT
Tcp 0 52 192.168.128.129: 22 192.168.128.1: 1297 ESTABLISHED
Tcp 0 0 192.168.128.129: 50968 61.135.185.247: 80 ESTABLISHED
Tcp 0 0 192.168.128.129: 9000 192.168.128.129: 34847 ESTABLISHED
Tcp 0 0: 34803: * LISTEN
Tcp 0 0: 22: * LISTEN
Tcp 0 0: 1: 631: * LISTEN
Tcp 0 0: 8088: * LISTEN
Tcp 0 0: 13562: * LISTEN
Tcp 0 0: 8030: * LISTEN
Tcp 0 0: 8031: * LISTEN
Tcp 0 0: 8032: * LISTEN
Tcp 0 0: 8033: * LISTEN
Tcp 0 0: 8040: * LISTEN
Tcp 0 0: 8042: * LISTEN
Tcp 0 0: ffff: 192.168.128.129: 8031: ffff: 192.168.128.12: 58051 ESTABLISHED
Tcp 0 0: ffff: 192.168.128.12: 58051: ffff: 192.168.128.129: 8031 ESTABLISHED 4) Start the MySql Service
[Root @ hadoop Mysql] # service mysql start
Starting MySQL ...... SUCCESS! 5) install the client
[Root @ hadoop Mysql] # rpm-ivh MySQL-client-5.6.22-1.linux_glibc2.5.x86_64.rpmPreparing... ######################################## ### [100%] 1: mySQL-client ^ C ################################### ######## [100%] installation completed 5) several important directories of MySQL. After MySQL is installed, its database files, configuration files, and command files are not installed in the same directory by default on SQL Server. It is very important to understand these directories, especially for Linux beginners, the directory structure of Linux itself is complicated. If you cannot figure out the installation directory of MySQL, you won't be able to learn it in depth. A. Database directory/var/lib/mysql/B, configuration file/usr/share/mysql (mysql. server commands and configuration files) c, related commands/usr/bin (mysqladmin mysqldump and other commands) d, startup script/etc/rc. d/init. d/(directory for starting the script file mysql) such as:/etc/rc. d/init. d/mysql start/restart/stop/status 6) change the MySQL directory. Because the MySQL database directory occupies a large disk, the default data file storage directory of MySQL is/"var/lib/mysql ", you can also move the data directory to the "mysql_data" directory under the "/" root directory (you do not need to move it if you do the test ). Stop the MySql service process: the Default User Name of service mysql stop or mysqladmin-u root-p shutdownMySQL is "root". Here, "root" is not a short time to stop the MySql service process, in addition, the default "root" password is empty, so enter the password and press Enter. Move the entire "/var/lib/mysql" directory to "/mysql_data" mv/var/lib/mysql/mysql_data to find my. if the cnf configuration file does not exist in the "/etc/" directory. cnf configuration file, find the my-default.cnf file under "/usr/share/mysql/", copy one of the appropriate configuration files to "/etc/" and rename it "my. cnf. Command is as follows: cp/usr/share/mysql/my-medium.cnf/etc/my. cnf: edit the MySQL configuration file "/etc/my. cnf "to ensure that MySQL works properly, you need to specify" mysql. the location where the sock "file is generated, and the default encoding is modified to UTF-8. Run the following command: vim/etc/my. cnf [mysqld] # Add the following command socket =/var/lib/mysql. sockdatadir =/mysql_data/mysql # specify the storage directory here if your data storage location needs to be changed
Character-set-server = utf8

 

Lower_case_table_names = 1 # (note that after mysql is installed in linux, the default value is: case-sensitive for table names, case-insensitive for column names; # lower_case_table_names = 0 0: case-sensitive, 1: (Case Insensitive) Note: 1) In the last line, you can run it without adding this configuration during local installation. If you add or not, you have to check your own settings. 2) In this configuration file, you can also set the socket and datadir options in the [client] configuration. I do not have these options here (I will not configure it here because I only install MySql for testing ), I don't know the reason for the version. If you need to figure out how to use the version, Baidu first. 3) If you modify the data storage location directory, you can run the following command to modify the MySQL STARTUP script "/etc/rc. d/init. d/mysql "Finally, you need to modify the MySQL STARTUP script/etc/rc. d/init. d/mysql, modify datadir =/mysql_data/mysql. Vim/etc/rc. d/init. d/mysql 7) restart the MySQL service.Service mysql start ERROR: Starting MySQL ERROR! The server quit without updataing PID file... after Baidu, The solution is: vi/etc/selinux/config change SELINUX = enforcing to SELINUX = disabled and then save The disk and restart The machine, It must be restarted.. After a great deal of hard work, I hope it will work. As a result, the server cannot be started ..... Error displayed: Kernel panic-not syncing: Attempted to kill init PS: Too bad. Installing MySQL is so expensive... After Baidu finds a new solution: when the solution system is started, press 'e' to go To the grub editing page and edit the grub menu, select the "kernel/vmlinuz-2.6.23.1-42.fc8 ro root =/dev/vogroup00/logvol00 rhgb quiet" column, press the 'E' key to enter the edit, and add enforcing = 0 at the end, that is: kernel/vmlinuz-2.6.23.1-42.fc8 ro root =/dev/vogroup00/logvol00 rhgb quiet enforcing = 0
Press the 'B' key to continue the guide, and OK will proceed smoothly. Well, we finally got to the Linux system and started the MySQL service: service mysql start. An error is prompted:MySQL: Starting MySQL ..... ERROR! The server quit without updating PID file solution is because MySQL does not initialize The table/usr/bin/mysql_install_db -- user = mysqlservice mysql start and you can restart The MySQL service. PS: it is not easy to install MySql ..... 8) change the logon PasswordMySQL does not have a password by default. It is self-evident that the password is added after installation. Before modification, log on directly to check whether the MySql port is Enabled: [root @ hadoop ~] # Netstat-ntlp | grep 3306tcp 0: 3306 :::: * LISTEN 5052/mysqld $: mysql ERROR: ERROR 2002 (HY000 ): can't connect to local MySQL server through socket '/var/lib/mysql. sock '(2) it is found that the socket location of the MySql server is different from that of the MySql server. Modify/etc/my.cn to modify socket =/var/lib/mysql. sock -- save; enter [root @ hadoop init. d] # mysql again and report an error...
ERROR 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: NO) Baidu solution: [root @ hadoop ~] # Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking & mysql-u root mysql enter again: [root @ hadoop ~] # MysqlWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 2 Server version: 5.6.22 MySQL Community Server (GPL) Copyright (c) 2000,201 4, Oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. other names may be trademarks of their respectiveowners. type 'help; 'or' \ H' for help. type '\ C' to cl Ear the current input statement. mysql> OK. the installation is successful... Enter "mysql" to log on to the MySQL database before adding a password. Change logon password: [root @ hadoop ~] Mysqladmin-u root password 'root' format: mysqladmin-u username-p old password new password if the new password has been connected to MySql, you can use the following statement: mysql> use mysql;
Mysql> UPDATE user SET Password = PASSWORD ('root') where USER = 'root'; Query OK, 4 rows affected (0.04 sec) Rows matched: 4 Changed: 4 Warnings: 0 modified successfully; this article reference blog: http://www.cnblogs.com/xia520pi/archive/2012/06/12/2546261.html thanks xipi Studio

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.