Linux, mac install MySQL

Source: Internet
Author: User
Tags gpg mysql version

1. Install dependent libraries
Yum-y Update
2. Add MySQL Yum repository
wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
RPM-UVH mysql-community-release-el6-5.noarch.rpm
3. Add/etc/yum.repos.d/mysql-community.repo
Vim/etc/yum.repos.d/mysql-community.repo
Add content
# Enable to use MySQL 5.6
[Mysql56-community]
Name=mysql 5.6 Community Server
baseurl=//repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
Enabled=1
Gpgcheck=1
Gpgkey=file:/etc/pki/rpm-gpg/rpm-gpg-key-mysql

4. Install MySQL with yum
Yum Install Mysql-community-server
5. Clear old database files
Mv/var/lib/mysql/var/lib/mysql-bak
6. Start MySQL
Service mysqld Start--Start
Service mysqld stop--stop
Service MYSQLD Status--state
7. Yum Install MySQL directory description
/var/log/mysqld.log #MySQL日志目录
/var/lib/mysql #MySQL数据文件目录
/usr/share/mysql/#MySQL配置文件目录
/usr/bin/#MySQL启动脚本目录
8. Set User
CREATE user Test_user;
Use MySQL;
UPDATE user SET Password=password ("Test_password") WHERE user= ' Test_user ';
GRANT all on * * to ' test_user ' @ '% ';
FLUSH privileges;
9. Set the default character encoding
Add MY.CNF (Ignore this step if this file is present)
Show variables like ' character_set_% ';
Querying database encoding
Cp/usr/share/mysql/my-default.cnf/etc/my.cnf
Modify/ETC/MY.CNF

Added content: Character_set_server=utf8

====================----=================== Below is reproduced in the original text

Linux:cenos 6.5
MySQL version: mySQL5.6.30
There are some differences between Mysql5.6.30 installation and mySQL5.1 installation, and you need to use CMake to configure the installation information. It is said that MySQL needs cmake to install from 5.5 onwards.
Mysql5.6.30 There is no configure, can't pass./configure installation configuration, you need to generate configuration information

MySQL5.6.30 Pre-installation ready to create MySQL user with MySQL group

Create group: Groupadd MySQL
Create User: Useradd-r-g MySQL MySQL

Create MySQL folder in data store folder

Mkdir-p/usr/local/mysql/data

Installing CMake


Of course you can also use the Yum install command below
Yum Install Cmake-y

Installation Information configuration

CMake. -dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=/usr/local/mysql/mysql.sock-ddefault_charset=utf8- Ddefault_collation=utf8_general_ci-dextra_charsets=all-dwith_innobase_storage_engine=1-dwith_archive_storage_ Engine=1-dwith_blackhole_storage_engine=1-dmysql_datadir=/usr/localhost/mysql/data

Execute make && make install

Make the appropriate configuration

1.conf: For saving MySQL configuration information
Mkdir/usr/local/mysql/conf
2.var: Used to store MySQL runtime files
Mkdir/usr/local/mysql/var
3. Move the my-default.cnf inside the support-files into the Conf and change the name to MY.CNF

4. Assigning Permissions
Chown-r Mysql:mysql/usr/local/mysql

Initialize MySQL


/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --skip-name-resolve--user=mysql --defaults-file=/usr/local/mysql/conf/my.cnf--pid-file=/usr/local/mysql/var/mysql.pid--socket=/usr/local/mysql/var/mysql.sock 

Start and close MySQL

Start: Support-files/mysql.server start
Close: Support-files/mysql.server stop

Connect to MySQL

Directory structure after MySQL is installed

Before starting and comparing as

Installation may experience problems resolving issues 1

./configure when you report a mistake, you can try to solve it
MySQL installation:/bin/rm:cannot remove libtoolt‘: No such file or directory . 
编译MySQL的过程中提示: 
/bin/rm: cannot remove
libtoolt ': No such file or directory
Solve:
1, confirm whether Libtool has been installed, if not installed, first install Libtool

Yum-y Install Libtool

2. Execute the following three commands respectively:

Autoreconf–force–installlibtoolize–automake–forceautomake–force–add-missing

Re-compile the installation, solve the problem!

Question Two

Missing Ncurses-devel Package
The error message is as follows

Resolution version
Solution (CentOS)
Yum List|grep ncurses
Yum-y Install Ncurses-devel

Question Three

When performing mysql_install_db initialization of MySQL
Found already exists my.cn file, it is likely that the system was installed before MySQL did not uninstall clean caused by

my.cn files are as follows

This causes the Mysql.sock file to not be generated in the local Usr/local/mysql/var
Workaround:
Remove/etc/my.cn, and then re-initialize
Question four: If you start MySQL, you cannot find the * *. pid file problem
The problem error interface is as follows

Modify the MY.CNF configuration file to specify the file where the database resides, as follows

Executive Bin/mysqld_safe &
In the execution support-files/mysql.server start

=============mac OS X Yosemite under Installation mysql=============

First go to the official website good MySQL installation package, remember to choose the Mac version: mysql-5.7.12-osx10.11-x86_64.tar.gz

Note: The default installation path for MySQL

so to move the unzip directory to the MySQL default installation path/usr/local/mysqlDown,/usr/localif the path does not exist, firstsudo mkdir /usr/localcreated.

# Move the unpacked binary package to the installation directorysudo mv mysql-5.6. --osx10.9-x86_64/usr/Local/mysql# Change the MySQL installation directory to the user and user groupCD/usr/Localsudo chown-r root:wheel MySQL# Perform some default initialization (create default configuration file, authorization table, etc.) by executing the mysql_install_db script in the scripts directoryCD/usr/Local/mysqlsudo scripts/mysql_install_db--user=mysql
 Note: MySQL 5.7  .6  The Scripts directory was canceled, the init command changed to sudo bin/mysqld--initialize--user=mysql 
CD/usr/Local/mysql# Startsudo support-files/mysql.server start# Restartsudo support-files/mysql.server restart# Stopsudo support-files/mysql.server stop# check MySQL run statussudo support-files/mysql.server status
# requires MySQL to execute in Run StateCD/usr/Local/mysql/bin./mysqladmin-u Root Password <your-password>
cd /usr/local/mysql/bin./mysql -u root -p<your-password>



Linux, mac install MySQL

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.