Environment: centos7,mysql5.5
1.mysql5.5 Source Download
Oracle's Web site is slow to open, http://mirrors.sohu.com/mysql/provides the image of MySQL here. In general, Linux programs are installed in two ways: a manually installed using tool b such as Rpm,yum. There are two ways of manual installation, one is to download the binary files that have been compiled directly, and the other is to download the source code manually compiled. Here we try to download the source code manual compilation method.
How to distinguish the files downloaded from the file list is a compiled binary file, or the source file:
A. File size. Since the source code is compiled into binary files, some static chain libraries are used. Therefore, the general source code file is smaller than compiling the binary file.
B. File name. Because the binary files compiled by different platforms are not the same, the package name of the generic compiled binary will explicitly write out the platform that the package applies to. such as mysql-5.5.40-linux2.6-x86_64.tar.gz. And the source code is generally not written like this.
C. After unpacking the downloaded file, if there is a bin folder, it is generally possible to indicate that the package is a compiled binary file.
2. Compiling the source code
- MySQL starts with the CMake compilation tool from 5.5. First install Cmake:yum installed CMake
- Create a MySQL user
12
- Unpacking: Tarball the/USR/LOCAL/SRC under the
1 #tar -zxvf mysql-5.5. . Tar
- Building the Makefile File
1#cd mysql-5.5. -/2#cmake-DCMAKE_INSTALL_PREFIX=/USR/LOCAL/MYSQL5.5 3-dmysql_unix_addr=/tmp/Mysql.sock4-ddefault_charset=UTF85-ddefault_collation=Utf8_general_ci6-dwith_extra_charsets:string=UTF8,GBK7-dwith_myisam_storage_engine=1 8-dwith_innobase_storage_engine=1 9-dwith_memory_storage_engine=1 Ten-dwith_readline=1 One-denabled_local_infile=1 A-dmysql_datadir=/var/mysql/Data --dmysql_user=MySQL --DSYSCONFDIR=/ETC # mysql config file my.cnf storage address, default to/etc under the-dmysql_tcp_port=3306# database server listening port, default is 3306 --dwith_ssl=Yes # support SSL --dmysql_user=MySQL # defaults to MySQL - + //The following 3 are database encoding settings --dextra_charsets=All # installs all extended character sets, default to all +-ddefault_charset=UTF8 # using UTF8 characters A-ddefault_collation=Utf8_general_ci # Check character at - //The following 5 are database storage engines located in the --dwith_myisam_storage_engine=1# Install the MyISAM storage engine --dwith_innobase_storage_engine=1# Install the InnoDB storage engine --dwith_archive_storage_engine=1# Install the archive storage engine --dwith_blackhole_storage_engine=1# Install the Blackhole storage engine in-dwith_partition_storage_engine=1# Install database partition
In this process, may be due to the lack of certain packages and error, refer to the error information with Yum to install the relevant package, and then delete Makefile.txt, rebuild. This step is described in detail in the error message
Performing the installation
1 #make 2 #makeinstall
3. Create a Database
- Setting up the configuration file
1#CPsupport-files/my-medium.ini/etc/my.cnf2 //MySQL provides My-small.ini, My-medium.ini, My-large.ini, my-huge.ini several files, according to the actual environment to choose the appropriate file for reference3 4 //Uncomment the following if you is using InnoDB tables5#innodb_data_home_dir =/var/mysql5.5/Data6#innodb_data_file_path =Ibdata1:10m:autoextend7#innodb_log_group_home_dir =/var/mysql5.5/Data8 9# default-storage-engine=InnoDBTen# user = MySQL
Other configurations are adjusted to the actual situation and are effective after restarting MySQL
Create a database
1 #./scripts/mysql_install_db--basedir=/usr/local/mysql5. 5 --datadir=/var/mysql5. 5
2 # Export Path=/usr/local/mysql5.5/bin: $PATH
Start/Close Database
1 #./bin/mysqld_safe &
Description
A. When the database is started, a message will be typed: Mysqld_safe Logging to '/usr/local/mysql5.5/data/localhost.err
If the database startup is unsuccessful, you can refer to this log for specific reasons, such as:
/usr/local/mysql5.5/bin/mysqld:file './mysql-bin.000004 ' not Found (errcode:13)
This problem is caused by file permissions, we are in the installation process due to root and MySQL and other users cut off, resulting in MySQL users do not have the correct access to file solutions
#chown-R mysql:mysql/usr/local/mysql5.5 Note the-r parameter
B. Even if the database starts normally, some of the warning messages in a log mentioned in A are also of reference value
2 #./bin/mysqladmin-u root-p Shutdown
Connecting to a database
1 #mysql- H localhost-u root-p
Some of the errors that occurred
1. ' Access denied for user ' root ' @ ' localhost ' (using Password:yes) ':
Occurs because the root password is not set correctly, if you connect directly to the database Mysql-u root and execute select password from user where user= ' root ',
You will find that the password are empty. In this case, if you do not reset password, then you can execute #mysql-h localhost-u root-p, and then when you need to enter the password, you can login directly, because the root password is empty. Of course, it's a good idea to reset the root password.
Linux MySQL5.5 Source Installation