In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
MySQL is a relational database management system developed by the Swedish company MySQL AB and currently belongs to the products of Oracle. MySQL is the most popular relational database management system, and MySQL is one of the best applications in WEB applications.
There are many ways to install mysql database. This article introduces the source code installation.
System environment:
Linux mysql 2.6.32-642.6.1.el6.x86_64 # 1 SMP Wed Oct 5 00:36:12 UTC 2016 x86'64 GNU/Linux
[root@mysql ~] # cat / etc/redhat-release
CentOS release 6.8 (Final)
Create users and groups
Groupadd mysql
Useradd mysql-g mysql-M-s / sbin/nologin
[root@mysql ~] # id mysql
Uid=502 (mysql) gid=502 (mysql) group = 502 (mysql)
two。 Extract the source code and compile and install
Tar xf mysql-5.1.72.tar.gz
Cd mysql-5.1.72
# compiling
. / configure\
-- prefix=/application/mysql5.1.72\
-- with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock\
-- localstatedir=/application/mysql5.1.72/data\
-- enable-assembler\
-- enable-thread-safe-client\
-- with-mysqld-user=mysql\
-- with-big-tables\
-- without-debug\
-- with-pthread\
-- enable-assembler\
-- with-extra-charsets=complex\
-- with-readline\
-- with-ssl\
-- with-embedded-server\
-- enable-local-infile\
-- with-plugins=partition,innobase\
-- with-mysqld-ldflags=-all-static\
-- with-client-ldflags=-all-static
Make & & make install
3. Make a soft link
Ln-s / application/mysql5.1.72/ / application/mysql
Ll / application/mysql
-
Important: if mysql is not deployed on the same computer as apache, that's it.
-
4. Initialization of database
Cd / tools/mysql-5.1.72
Ls support-files/my*.cnf # display mysql configuration file
Cd support-files
Cp my-small.cnf / etc/my.cnf # copy configuration file
Mkdir-p / application/mysql/data # create a directory for storing mysql data files
Chown-R mysql:mysql / application/mysql # authorized Mysql users can access the installation directory of mysql
Ll / application/mysql/data
/ application/mysql/bin/mysql_install_db-basedir=/application/mysql-datadir=/application/mysql/data-user=mysql
# 2 OK appears, indicating success
Ll / application/mysql/data
# #
Vim / etc/init.d/mysqld
Basedir=/application/mysql
Datadir=/application/mysql/data
# #
5.copy startup file
Cd / tools/mysql-5.1.72/support-files
Cp mysql.server / etc/init.d/mysqld
6. Join the boot self-boot
Chkconfig mysqld on
Start the mysql database
/ etc/init.d/mysqld start (/ application/mysql/bin/mysqld_safe & this command can also start mysql)
If startup fails, execute the following command:
Ps-ef | grep mysql # check whether the Mysql process is running, and if so, Kill or mysqladmin shutdown before starting
Then start mysql again
[root@mysql ~] # mysql
The following error occurred:
#-bash:mysql:command not found
The path corresponding to mysql is not under the path directory.
Use the full path to enter mysql:
/ application/mysql/bin/mysql
Or add at the end of the document:
Vi / etc/profile
PATH= "/ application/mysql/bin/:$PATH"
[root@mysql] #. / etc/profile # to make it effective
# set password, do not set password under mysql >, set password after #
/ application/mysql/bin/mysqladmin-u root password 'passwd123'
# sign in again and enter your user name and password
Mysql-u root-p
Passwd123
7. Data optimization:
Select version (); # View the database version
Select user (); # View current users
Mysql > show databases; # View the database
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | test |
+-+
Mysql > drop database test; # security settings, delete useless databases
The final optimization is as follows:
Mysql > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
+-+
Mysql > select user,host from mysql.user; # query the users in the table
+-+ +
| | user | host |
+-+ +
| | root | 127.0.0.1 | |
| | localhost |
| | root | localhost |
| | weblamp |
| | root | weblamp |
+-+ +
Drop user "@ webl # Delete hostname is weblamp, user name =".
Mysql > drop user "" @ localhost
Mysql > drop user "root" @ weblamp
The final optimization is as follows:
Mysql > select user,host from mysql.user
+-+ +
| | user | host |
+-+ +
| | root | 127.0.0.1 | |
| | root | localhost |
+-+ +
If it cannot be deleted, use delete to delete it.
Delete from mysql.user where (host= "weblamp")
Finally refresh:
Flush privileges
# if you forget your login password, you can use this to skip the entry of login password
/ application/mysql/bin/mysqld_safe-skip-grant-table &
# change password
Mysql > update mysql.user set password=PASSWORD ("oldboy123") where host='localhost' and user='root'
Flush privileges
[root@mysql ~] # lsof-I: 3306 # View the current operation of port 3306
# View mysql's log
Cat / application/mysql/data/oldboy.err
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.