Alibaba ECS CentOS Linux installation MySQL-5.5.27

Source: Internet
Author: User

Alibaba ECS CentOS Linux installation MySQL-5.5.27
Note: My ECS has just been rented purely, and all environments need to be set up by myself. This article is a complete process from start to end. I have read a lot of information on the Internet, which is very enlightening, however, the installation failed many times. I did not succeed either through the rpm file or yum installation. Finally, I decided to install it through the compressed package, everything went smoothly! Now let's start this sharing! Instructions for use: (1). The path in this installation is for reference only (2). xshell for connection tools and xftp for file transfer tools
1. Install cmakeCommand: yum install-y cmake: cmake is the makefile tool. It aims to generate a portable makefile and simplify the huge workload of writing makefile by yourself.
2. install the make command: yum install-y make command. The most important and basic function of the Make tool is to use the makefile file to describe the relationship between source programs and automatically maintain the compilation work. The makefile file needs to be compiled according to a certain syntax. The file must describe how to compile each source file and generate an executable file, and define the dependency between the source files.
3. log on to the/usr/local/directory (Please click "mysql1_mysql-5.5.27" in the Directory and the compressed file" mysql-5.5.27.tar.gz ". Therefore, the command is not installed.) command: cd/usr/local/

4. create the mysql directory and mysql/data directory, mysql is used to install mysql-5.5.27, data is used to store database commands: mkdir-p/usr/local/mysql/data
5.download the mysqlcompressed package mysql-5.5.27.tar.gz. Method 1: Use the wget command to directly download the package to the local directory through a network connection;
Method 2: Download the compressed package in advance and transfer it to the local directory through xftp. The two are similar. Compressed package Network: After the download is complete, a mysql-5.5.27.tar.gz file is added under the local directory

6. decompress the compressed package command: tar-zxvf mysql-5.5.27.tar.gz command details:-z: Decompress with gzip-x: read from the specified file list of files you do not want to include-v: show processed file list-f: After script F is decompressed at the end of each disk, the local directory has an additional mysql-5.5.27 directory

7. Go to directory mysql-5.5.27 command: cd mysql-5.5.27

8. Use the cmake command. The command content can be directly copied without modification (premise: the mysql and data paths mentioned earlier are consistent with mine). Command content: cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/usr/local/mysql/data/mysql. sock \
-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_EXTRA_CHARSETS: STRING = utf8, gbk \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/usr/local/mysql/data /\
-DMYSQL_USER = mysql-DMYSQL_TCP_PORT = 3306 Note: \ cannot be omitted

9. Run the make command: make

10. Run the make install command: make install

11. set my. cnf copy and rename to/usr/local/mysql/support-files/my-dedium.cnf command: cp/usr/local/mysql/support-files/my-medium.cnf/etc/my. cnf

12. chmod 755 scripts/mysql_install_db change permission of the file directory Description: chmod abc file contains a number for each a, B, and c, indicating the permissions of the User, Group, and Other respectively. R = 4, w = 2, x = 1 if you want the rwx attribute, 4 + 2 + 1 = 7; if you want the rw-attribute, 4 + 2 = 6; if you want the r-x attribute, 4 + 1 = 7. Example: chmod a = rwx file and chmod 777 file have the same effect as chmod ug = rwx, o = x file and chmod 771 file have the same effect. If chmod 4755 filename is used, the program has root permissions: The owner has read, write, and execute permissions; group users and other users only have read and execution permissions.

13. initialize the database (Similarly, if the directory is the same as mine, the command can not be modified) command content: scripts/mysql_install_db \
-- User = mysql \
-- Basedir =/usr/local/mysql \
-- Datadir =/usr/local/mysql/data/
So far, mysql has been installed successfully. You can use the mysql command to test it. There are some other settings in the future.
14. Copy the Startup File to start the startup command: cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysql

15. Change the permission command of/etc/init. d/mysql: chmod 755/etc/init. d/mysql

16. Set the boot command: chkconfig mysql on

17. Add the bin directory of mysql to the environment variable. Command: echo 'export PATH =/usr/local/mysql/bin: $ path'>/etc/profile

18. Run the following command to make the environment variable take effect: source/etc/profile

19. Start mysql. If mysql cannot be started, reboot restarts the server.

20. Run the "netstat-nat | grep 3306" command to view port 3306 status.

21. Open Port 3306 in the firewall. Edit and edit iptables. If this file is not available, run vi/etc/sysconfig/iptables (vim is also supported)

22. Add-a input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT to the file: wq to save the modification.

23. Restart the Firewall

24. log on to mysql and set the new password (1) first LOGIN command: mysql and then set the password (2) Non-first LOGIN command: mysql-u root-p and then enter the password to log on.
If the message "ERROR 1044 (42000): Access denied for user'' @ 'localhost' to database 'mysql' is displayed '. The reason is that the user table of the mysql database contains an account with an empty username, that is, an anonymous account. As a result, the root account is used for logon, but the logon is actually anonymous, you can see the '@ 'localhost' in the error message.


25. set the new password mysql> use mysql; mysql> update user set password = password ("123456 ");

26. Currently, navicat cannot connect to the database remotely. Therefore, you must enable allow remote connection to the database mysql> select 'host', 'user' from User;
Set Host to % to allow remote connection
Finally, restart the mysql service and run the command:/etc/init. d/mysql restart to test the connection. Enter the IP address, account, and password to log on.


27. At last, this database only supports Administrator Logon, that is, root user. create other users first.
Test connection

Now, the complete installation process for mysql in Linux is over and shared with you! I am also a newbie, and it is inevitable that I have some mistakes. Please forgive me. You can reply with any good suggestions!

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.