mysql-Simple Installation

Source: Internet
Author: User

installing Msqyl on CentOS

Check to see if the MySQL database is already installed on our operating system using the following command

[Email protected] ~]# Rpm-qa |    grep MySQL #这个命令就会查看该操作系统上是否已经安装了mysql数据库有的话, we'll uninstall it by RPM-E command or rpm-e--nodeps command [[email protected] ~]# rpm-e MySQL  #普通删除模式 [[email protected] ~]# rpm-e--nodeps MySQL #强力删除模式, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly removed after deletion we can through RPM-QA | grep mysql command to see if MySQL has been uninstalled successfully!

First , compile and install MySQL before the preparatory work

1. Install the tools and libraries needed to compile the source code.

Yum install gcc gcc-c++ ncurses-devel perl

2, install CMake, download the source code from http://www.cmake.org and compile the installation

wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz

TAR-XZVF cmake-2.8.10.2.tar.gz

CD cmake-2.8.10.2

./bootstrap; make; Make install

second, set up MySQL users and groups

1. New MySQL user group

Groupadd MySQL

2. New MySQL User

Useradd-r-G MySQL MySQL

Iii. directories required for new MySQL

1. New MySQL installation directory

Mkdir-p/usr/local/mysql

2. New MySQL database data file directory

Mkdir-p/data/mysqldb

Download the MySQL source package and unzip it.

Download the source code directly from http://dev.mysql.com/downloads/mysql/

wget http://www.kakapart.com/files/mysql-5.6.16.tar.gz

Tar-zxv-f mysql-5.6.16.tar.gz

CD mysql-5.6.16

v. Compile and install MySQL

1, from mysql5.5, MySQL source installation started using CMake, set the source code compilation configuration script.

CMake \

-dcmake_install_prefix=/usr/local/mysql \

-dmysql_unix_addr=/usr/local/mysql/mysql.sock \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-dwith_innobase_storage_engine=1 \

-dwith_archive_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

-DMYSQL_DATADIR=/DATA/MYSQLDB \

-dmysql_tcp_port=3306 \

-denable_downloads=1

Dcmake_install_prefix=dir_name

Setting up the MySQL installation directory

-dmysql_unix_addr=file_name

Set the listener socket path, which must be an absolute pathname. Default is/tmp/mysql.sock

-ddefault_charset=charset_name

Sets the character set of the server.

By default, MySQL uses the latin1 (CP1252 Western European) character set. The Cmake/character_sets.cmake file contains a list of allowed character set names.

-ddefault_collation=collation_name

Sets the collation of the server.

-DWITH_ innobase_storage_engine=1

-dwith_archive_storage_engine=1

-dwith_blackhole_storage_engine=1

-dwith_perfschema_ storage_engine=1

storage engine options:

 

myisam,merge,memory, and the CSV engine are compiled to the server by default and do not need to be explicitly installed.

 

 

-dmysql_datadir=dir_name

Set the MySQL database file directory

-dmysql_tcp_port=port_num

Set the MySQL server listening port, default to 3306

-denable_downloads=bool

Whether you want to download the optional files. For example, if you enable this option (set to 1), CMake will download the test suite that Google uses to run unit tests.

Note: To rerun the configuration, you need to delete the CMakeCache.txt file

RM CMakeCache.txt

vi. modifying MySQL directory owners and Groups

1. Modify the MySQL installation directory

Cd/usr/local/mysql

Chown-r Mysql:mysql. #注意后面的小数点 that represents the current directory and cannot be omitted.

2. Modify the MySQL database file directory

Cd/data/mysqldb

Chown-r Mysql:mysql. #注意后面的小数点

[Email protected] mysql]# pwd/usr/local/mysql[[email protected] mysql]# chown-r mysql:mysql.    [Email protected] mysql]# cd/data/mysqldb/[[email protected] mysqldb]# chown-r mysql:mysql.  

vii. initializing MySQL database
cd/usr/local/mysqlscripts/mysql_install_db--user=mysql--datadir=/data/mysqldb

When initializing MySQL, the following error occurs if the machine name cannot be reversed

[Email protected] mysql]# scripts/mysql_install_db--user=mysql--datadir=/data/mysqldb warning:the host ' LCJ ' could no T is looked up with./bin/resolveip. This probably means that your libc libraries is not the Compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving won't work. This means the should use IP addresses instead of Hostnameswhen specifying MySQL privileges! Installing MySQL system tables ... 2016-07-28 08:41:24 0 [Warning] TIMESTAMP with implicit the DEFAULT value is deprecated. --explicit_defaults_for_timestamp server option (see documentation for more details).

How to resolve:

See if there is a response machine name in the/etc/hosts file, and add the native IP to the machine's corresponding to the/etc/hosts file, if none

Use RESOLVEIP to confirm if OK

[Email protected] mysql]#/usr/local/mysql/bin/resolveresolveip           resolve_stack_dump  

To initialize MySQL again:

viii. copy mysql service startup configuration file
CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF #注: Overwrite if the/etc/my.cnf file exists

ix. copy MySQL service startup script and join path path
CP Support-files/mysql.server/etc/init.d/mysqldvi/etc/profileexport path=/usr/local/mysql/bin:/usr/local/mysql/ Lib: $PATH source/etc/profile #使用环境变量生效chown-R mysql:mysql. #注意后面的小数点

10. Start the MySQL service and join the boot
Service mysqld Startchkconfig--level mysqld on

11. Check if the MySQL service is started
NETSTAT-TULNP | grep 3306mysql-u root-p #密码为空, if you can log on, the installation is successful.

12. Modify the password of the MySQL user root
mysqladmin-u root password ' 123456 '

Note: You can also run the security settings script, modify the password of the MySQL user root, and disable the root remote connection, remove the test database and anonymous users.

/usr/local/mysql/bin/mysql_secure_installation

mysql-Simple Installation

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.