Centos7 installing MySQL

Source: Internet
Author: User
Tags install openssl

Centos7 installing MySQL


1 Find out if the system has MYQL installed
Rpm-q MySQL Mysql-server
1.1 If it is installed. Just delete
sudo yum-y remove MySQL mysql-server
sudo rm-rf/etc/my.cnf


2 Installation Dependencies
sudo yum install ncurses-devel-y
sudo yum install libaio-devel-y
sudo yum install bison-y
sudo yum install openssl-devel-y
sudo yum install gcc-y
sudo yum install gcc-c++
sudo yum install cmake-y
sudo yum install make-y

3 Installing MySQL
1 Creating MySQL Users and user groups
Groupadd MySQL
Useradd-m-G mysql-s/sbin/nologin MySQL

Description
-M force no user directory creation
-g Specifies the user group,
-s/sbin/nologin settings MySQL user cannot log on as user
MySQL is the user name

2 Creating a MySQL installation directory and database storage directory
sudo mkdir-p/usr/local/mysql
sudo mkdir-p/usr/local/mysql/data

3 Decompression
Tar XF mysql-5.5.50.tar.gz

4 Installation
CMake \
-DCMAKE_INSTALL_PREFIX=/USR/LOCAL/MYSQL \ Installation Location
-DSYSCONFDIR=/ETC \ Configuration file directory
-dmysql_datadir=/usr/local/mysql/data \ Database Location
-dmysql_tcp_port=3306 \ mysql listener port-dmysql_unix_addr=/tmp/mysql.sock \ Socket File
-ddefault_charset=utf8 \ Default Character
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \ Character Set
-denabled_local_infile=1 \ Allow importing data from local
-dwith_readline=1 \//shortcut key function
-dwith_ssl=system \
-dwith_extra_charsets=all \
-dwith_embedded_server=1 \//compile into EMBEDDED MySQL library (LIBMYSQLD.A)
-dwith_innobase_storage_engine=1 \ Installing the InnoDB storage engine
-dwith_myisam_storage_engine=1 \ Installing the MYISAM storage engine
-dinstall_mandir=/usr/share/man


Equivalent to the following

sudo cmake-dcmake_install_prefix=/usr/local/mysql-dinstall_mandir=/usr/share/man-dsysconfdir=/etc-dmysql_ Datadir=/usr/local/mysql/data-dmysql_tcp_port=3306-ddefault_charset=utf8-ddefault_collation=utf8_general_ci- Denabled_local_infile=1-dwith_readline=1-dwith_ssl=system-dwith_extra_charsets=all-dwith_embedded_server=1- Dwith_innobase_storage_engine=1-dwith_myisam_storage_engine=1


If CMake fails to execute RM CmakeCache.txt, make clean, and then re-cmake


Execute, sudo make


5 Execute sudo make install

6 sudo chown-r mysql:mysql mysql/

7 Initialize MySQL--user=mysql to show MySQL user
sudo./scripts/mysql_install_db--user=mysql--datadir=/usr/local/mysql/data

8
[email protected] support-files]$ sudo cp my-huge.cnf/etc/my.cnf
[email protected] support-files]$ sudo cp mysql.server/etc/init.d/mysqld
[email protected] support-files]$ sudo chmod 755/etc/init.d/mysqld
[[email protected] support-files]$ sudo chkconfig--add mysqld//Added to each boot level, can not be added

Set up auto run on boot
sudo chkconfig mysqld on
Start MySQL
sudo service mysqld start
sudo service mysqld stop

"Other startup MySQL mode:"
Mode one: Sudo/etc/init.d/mysqld start
Mode two: sudo start mysqld
Way three: sudo service mysqld start
Stop MySQL:
Mode one: Sudo/etc/init.d/mysqld stop
Mode two: sudo stop mysqld
Way three: sudo service mysqld stop
To restart MySQL:
Way One: sudo/etc/init.d/mysqld restart
Way two: sudo restart mysqld
Way three: sudo service mysqld restart

9 View mysql status ps aux | grep MySQL


10 log in to MySQL
[Add MySQL command tool to Path]
sudo echo "Export path= $PATH:/usr/local/mysql/bin" >>/etc/profile
Source/etc/profile

If you do not set a password to enter MySQL directly into the login, but this login can not see the MySQL library
So we recommend setting the password

[If you need to set a password]
Mysqladmin-uroot password ' root ' this is the code.


[Telnet] Virtual machine selection bridging mode
Authorized account remote connection, create an account account name is user1 password 123

Grant all on * * to [e-mail protected] '% ' identified by ' 123 ';
Grant all on * * to [e-mail protected] ' 192.168.56.1 ' identified by ' 123 ';






















Centos7 installing MySQL

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.