Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux install mysql database-- compile and install

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Http://www.cnblogs.com/xiongpq/p/3384681.html

one。 Download mysql5.6 version: http://dev.mysql.com/downloads/mysql/5.6.html#downloads

Two. Sign up for an oracle account:

Three. System package preparation

# yum-y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-devel* make cmake

Note: ncurses-devel is a dependent package for mysql and must be installed.

1. Prepare two source files: mysql-5.5.10.tar.gz and cmake-2.8.4.tar.gz

(1) install cmake first (mysql5.5 is later compiled through cmake. If yum has been successfully installed, this step can be ignored)

# tar-zxv-f cmake-2.8.4.tar.gz

# cd cmake-2.8.4

#. / configure

# make

# make install (2) create the installation directory and database storage directory for mysql # mkdir-p / usr/local/mysql/ install mysql# mkdir-p / usr/local/mysql/data / / store the database # chown-R mysql:mysql / usr/local/mysql/ / set the owner of all files in the current directory to mysql and belong to group mysql# chown-R 1777 / tmp/

(3) create mysql users and user groups # groupadd mysql# useradd-r-g mysql mysql

(4) install mysql# tar-zxv-f mysql-5.5.10.tar.gz

# cd mysql-5.5.10

# cmake.

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

-DMYSQL_DATADIR=/usr/local/mysql/data\

-DSYSCONFDIR=/etc\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_MEMORY_STORAGE_ENGINE=1\

-DWITH_READLINE=1\

-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock\

-DMYSQL_TCP_PORT=3306\

-DENABLED_LOCAL_INFILE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DEXTRA_CHARSETS=all\

-DDEFAULT_CHARSET=utf8\

-DDEFAULT_COLLATION=utf8_general_ci

# make

# make install

Parameter description:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql / / installation directory

-DINSTALL_DATADIR=/usr/local/mysql/data / / database storage directory

-DDEFAULT_CHARSET=utf8 / / use utf8 characters

-DDEFAULT_COLLATION=utf8_general_ci / / check character

-DEXTRA_CHARSETS=all / / install all extended character sets

-DENABLED_LOCAL_INFILE=1 / / allow data to be imported locally

Other more parameters http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

Note:

When recompiling, you need to clear the old object files and cache information.

# make clean

# rm-f CMakeCache.txt

# rm-rf / etc/my.cnf

two。 Database configuration

(1) MYSQL system service

# cd / usr/local/mysql# cp support-files/my-medium.cnf / etc/my.cnf / / add the configuration file of mysql to the system # cp support-files/mysql.server / etc/init.d/mysql / / add the startup service of mysql to the system service # cp support-files/mysql.server / etc/rc.d/init.d/mysql / / add the startup service of mysql to the system service # chmod + x / etc/init.d/mysql

Note: the main thing is to copy the mysql.server to / etc/init.d and name it mysql. In some systems, mysql.server is in / usr/local/mysql/share/mysql/mysql.server, while in this system, mysql.server is in / usr/local/mysql/support-files/mysql.server. Then use # service mysql start to start mysql. If you want the MySQL server to start every time the computer restarts, type the following command (as root user): $chkconfig mysql on (2) sets the environment variable (because the mysql command can only be executed in mysql/bin by default)

[root@ rhel5~] # vi / home/mysql/.bash_profile / / or modify the global environment variable / etc/profile, # echo 'export PATH=/usr/local/mysql/bin:$PATH > > / etc/pofileexport PATH=/usr/local/mysql/bin:$PATH:$HOME/bin / / Note here that the new mysql bin directory is added in front of the original PATH

/ / otherwise this problem may occur: http://oldboy.blog.51cto.com/2561410/1122867#tail-l / home/mysql/.bash_profile / / verify that the modification is correct # source / home/mysql/.bash_profile

4) create the table of the system database

# cd / usr/local/mysql/scripts#. / mysql_install_db-- basedir=/usr/local/mysql-- datadir=/usr/local/mysql/data-- user=mysql (5) manually start mysql

# cd mysql-5.5.10/mysql#. / bin/mysqld_safe-- user=mysql & / / start MySQL, but you cannot stop the startup log to be written in this file: / usr/local/mysql/data/localhost.err

Turn off the MySQL service [root@ rhel5 mysql] # mysqladmin-u root-p shutdown / / here the root user of MySQL has not configured a password, so it is null. When you need to enter the password, just click the enter key. (6) another simple way to start mysql (mysql has been added to the system service)

[root@ rhel5~] # / etc/init.d/mysql start [root@ rhel5~] # / etc/init.d/mysql stop [root@ rhel5~] # / etc/init.d/mysql restart [root@ rhel5~] # netstat-lntup | grep 3306 / / check whether mysql is started

If the above command appears: a service not recognized by mysql, then mysql may not have been added to the system service. Check the service file.

[root@szq init.d] # ll / etc/init.d/mysql

-rwxr-xr-x. 1 root root 10904 Apr 13 04:42 / etc/init.d/mysql

(7) change the password of the root user of MySQL and open remote connection

[root@ rhel5~] mysql

Mysql > select user,host from mysql.user

Mysql > delete from mysql.user where user =''

Mysql > delete from mysql.user where host =':: 1'

Modify root password method 1:

[root@ rhel5~] mysql-u root-p-- Login without password

Mysql > use mysql

Mysql > desc user

Mysql > GRANT ALL PRIVILEGES ON *. * TO root@ "%" IDENTIFIED BY "root"; / / the ability to add remote connections to root.

Mysql > update user set Password = password ('xxxxxx') where User='root'

Mysql > select Host,User,Password from user where User='root'

Mysql > flush privileges

Change root password method 2: [MySQL @ db_server1] $mysqladmin-u root-S / app/3308/mysql.sock password '123456' login: mysql-u root-p (8) Firewall setting mysql3306 port cannot be opened by default, if you cannot connect remotely, turn off the firewall. You can also allow it to pass with the following command. # vi / etc/sysconfig/iptables adds the following:-An INPUT-m state-- state NEW-m tcp-p-dport 3306-j ACCEPT# service iptables restart # / etc/rc.d/init.d/iptables stop

Note: if you cannot connect remotely and there is an error mysql error number 1130, try adding the following statement:

Mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' * 'WITH GRANT OPTION

Http://www.cnblogs.com/fly1988happy/archive/2011/11/21/2257682.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report