search
HomeBackend DevelopmentPHP TutorialSource code installation mysql-5.6.30 and mysql maintenance_PHP tutorial

Source code installation mysql-5.6.30 and mysql maintenance

Overview:

The MySQL installed through yum under CentOS 6.4 is version 5.1, which is relatively old, so I just want to install the higher version 5.6.30 through the source code.

Text:

1: Uninstall the old version

Use the following command to check whether MySQL Server is installed

rpm -qa | grep mysql

If yes, use the following command Command to uninstall

rpm -e mysql   //普通删除模式rpm -e --nodeps mysql    // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

2: Install MySQL

Install the packages needed to compile the code

yum -y install make gcc-c++ cmake bison-devel  ncurses-devel

Download MySQL 5.6.14

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.30.tar.gztar xvf mysql-5.6.14.tar.gzcd mysql-5.6.14

Compile and install

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_cimake && make install

For compilation parameters, please refer to http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.

The whole process takes about 30 minutes...a long wait

Three: Configure MySQL

Set permissions

Use the following command to check if there is a mysql user and user group

cat /etc/passwd 查看用户列表cat /etc/group  查看用户组列表

Create if there is none

groupadd mysqluseradd -g mysql mysql

Modify /usr/local/mysql permissions

chown -R mysql:mysql /usr/local/mysql

Modify /usr/local/mysql permissions

Initial configuration

Enter the installation path

cd /usr/local/mysql

Enter the installation path, execute the initialization configuration script, and create the database and tables that come with the system

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

Note: When starting the MySQL service, my.cnf will be searched in a certain order, first in the /etc directory, if not found, it will search for "$basedir/my.cnf", in this case /usr/ local/mysql/my.cnf, this is the default location of the configuration file of the new version of MySQL!

注意:在CentOS 6.4版操作系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。

在使用"yum update"更新系统后,需要检查下/etc目录下是否会多出一个my.cnf,如果多出,将它重命名成别的。否则,MySQL将使用这个配置文件启动,可能造成无法正常启动等问题。

启动MySQL

添加服务,拷贝服务脚本到init.d目录,并设置开机启动

cp support-files/mysql.server /etc/init.d/mysqlchkconfig mysql onservice mysql start  --启动MySQL

配置用户

MySQL启动成功后,root默认没有密码,我们需要设置root密码。

设置之前,我们需要先设置PATH,要不不能直接调用mysql

修改/etc/profile文件,在文件末尾添加

PATH=/usr/local/mysql/bin:$PATHexport PATH

关闭文件,运行下面的命令,让配置立即生效

source /etc/profile

现在,我们可以在终端内直接输入mysql进入,mysql的环境了

执行下面的命令修改root密码

mysql -uroot  mysql> SET PASSWORD = PASSWORD('123456');

若要设置root用户可以远程访问,执行

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.%' IDENTIFIED BY 'password' WITH GRANT OPTION;

红色的password为远程访问时,root用户的密码,可以和本地不同。

配置防火墙

防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口

打开/etc/sysconfig/iptables

在“-A INPUT –m state --state NEW –m tcp –p –dport 22 –j ACCEPT”,下添加:

-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT

然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:

service iptables restart

OK,一切配置完毕,你可以访问你的MySQL了~

------------------------------------------------------------------------------------------------------------------

Added on December 2, 2014:

CentOS 7 uses Firewalld as the firewall by default, so after modifying iptables, it will not work at all after restarting the system.

The method of adding a port in Firewalld is as follows:

firewall-cmd --zone=public --add-port=3306/tcp--permanent

firewall-cmd --reload


---------------------------------- -------------------------------------------------- ----------------------------
1: Add user
INSERT INTO mysql.user(Host,User,Password) values("%","dev",password("yihen382465"));
If you want to log in on any computer, replace localhost with %; you can also replace localhost with any IP, which means only allowed Log in with this IP;
If ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value, set the sql_mode in the configuration file to NO_ENGINE_SUBSTITUTION, and then restart mysql

2: Create a database
CREATE DATABASE distributorDEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

3: Grant the database
grant all privileges on distributor.* to dev@localhost identified by '123456';

4: Refresh privileges
flush privileges;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1129196.htmlTechArticleSource code installation mysql-5.6.30 and mysql maintenance overview: MySQL installed through yum under CentOS 6.4 is version 5.1 , is relatively old, so I want to install the higher version 5.6.30 through the source code. Text: 1:...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)