In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Install the dependency package first to avoid problems during installation
[root@bogon liuzhen] # yum-y install gcc gcc-c++ [root@bogon liuzhen] # yum-y install cmake [root@bogon liuzhen] # yum-y install ncurses-devel [root@bogon liuzhen] # yum-y install autoconf [root@bogon liuzhen] # yum-y install perl perl-devel
The installation above can also be done one by one.
[root@bogon liuzhen] # yum-y install gcc gcc-c++ cmake ncurses-devel autoconf perl perl-devel
Mysql × × address: https://dev.mysql.com/downloads/mysql/5.6.html#downloads
Source code packet address: https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz
Create a mysql installation directory and a data storage directory
[root@bogon liuzhen] # mkdir / usr/local/mysql [root@bogon liuzhen] # mkdir / usr/local/mysql/data
Mkdir create folder
-m: set access permissions for the new directory
-p: at this time, if some directories in the path do not already exist, the system will automatically establish those directories that do not already exist
Create users, user groups
[root@bogon liuzhen] # groupadd mysql [root@bogon liuzhen] # useradd-r-g mysql mysql
The useradd command, which is used to set up a user account and create a user's starting directory, is the ultimate user. The new user password is empty
-g: specify the starting group to which the user belongs.
-d: specify the starting directory when the user logs in.
-s: specifies the shell to be used by the user after logging in. -s / sbin/nologin is not allowed to log in to shell
The first mysql after-g is the group name, and the second mysql is the newly created user name. The new user information can be found in the / etc/passwd file.
Extract the file to the current folder
Tar backup, compression and decompression, Linux command, is also a tool
-z: indicates that the tar package is compressed by gzip, so you need to decompress it with gunzip.
-x: extract files from the tar package
-v: display details
-f xxx.tar.gz: specifies that the file being processed is xxx.tar.gz
Tar.gz is decompressed with tar zxvf and tar.bz2 is decompressed with tar jxvf
Start installation
[root@bogon liuzhen] # tar-zxvf mysql-5.6.35.tar.gz [root@bogon liuzhen] # cd mysql-5.6.35 [root@bogon mysql-5.6.35] # cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DINSTALL_DATADIR=/usr/local/mysql/data\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DEXTRA_CHARSETS=all\-DENABLED_LOCAL_INFILE= 1 [root @ bogon mysql-5.6.35] # make & & make install
CMAKE parameter description:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql / / default 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
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
For detailed configuration of CMAKE, please refer to the official website of mysql
Note:
If the installation fails to recompile, you need to clear the old object files and cache information.
[root@bogon mysql-5.6.35] # make clean [root@bogon mysql-5.6.35] # rm-f CMakeCache.txt [root@bogon mysql-5.6.35] # rm-rf / etc/my.cnf
Set directory permissions
[root@bogon liuzhen] # cd / usr/local/mysql [root@bogon mysql] # chown-R mysql:mysql. [root@bogon mysql] # chown-R mysql:mysql data
The chown command changes the owner and group of a file or directory.
-R: recursively changes the owner of the specified directory and all subdirectories and files under it.
-v: displays the work done by the chown command.
Add mysql startup service to the system service
[root@bogon liuzhen] # cd / usr/local/mysql [root@bogon mysql] # cp support-files/my-default.cnf / etc/my.cnf
Create the underlying table:
[root@bogon liuzhen] # cd / usr/local/mysql [root@bogon mysql] #. / scripts/mysql_install_db-- user=mysql
Configure environment variables
[root@bogon liuzhen] # vi / etc/profile
Add the following two values at the bottom
Export MYSQL_HOME= "/ usr/local/mysql"
Export PATH= "$PATH:$MYSQL_HOME/bin"
And then save.
Let the modified profile file take effect immediately
[root@bogon liuzhen] # source / etc/profile
Add mysql to the folder where you can control the startup of the service, and name mysql, that is, the name of the service that service can control. At this point, you can use service mysql start control to start mysql.
/ etc/init.d is a link to / etc/rc.d/init.d. Adding a file to / etc/init.d will synchronously add the same file under / etc/rc.d/init.d.
[root@bogon liuzhen] # cd / usr/local/mysql/ [root@bogon mysql] # cp support-files/mysql.server / etc/init.d/mysql
The chkconfig command is mainly used to update (start or stop) and query the run-level information of system services. Keep in mind that chkconfig does not automatically disable or activate a service immediately, it simply changes symbolic links
-- add: add the specified system service so that the chkconfig instruction can manage it, and at the same time add the relevant data to the narrative file started by the system. Service scripts must be stored in the / etc/ini.d/ directory
Add mysql service to the list of services managed by boot instructions
Chkconfig-add mysql
Boot self-starting mysql service
On: there is a level limit for the service. For more information, please query chkconfig.
Chkconfig mysql on
You can now start mysql using the following command
[root@bogon liuzhen] # service mysql start
Stop the mysql service
[root@bogon liuzhen] # service mysql stop
Restart the mysql service
[root@bogon liuzhen] # service mysql restart
The following two commands have the same effect
Systemctl [stop | start | restart] service name
Service service name [stop | start | restart]
Enter and set the new password in the following prompts.
[root@bogon liuzhen] # mysqladmin-u root passwordNew password: Confirm new password: [root@bogon liuzhen] #
Connect to mysql
[root@bogon mysql] # mysql-u root-p Enter password: Welcome to the MySQL monitor Commands end with; or\ g.Your MySQL connection id is 2Server version: 5.6.35 Source distributionCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql >
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; / / Refresh permission mysql > exit / / exit
Here are the remaining four GRANT examples
Assign user user1 from 192.168.155.1 to SELECT,INSERT,UPDATE,DELETE,CREATE,DROP and other operations on the tablename table of database dbname, and set the password to 123456.
There are many permissions to operate on the table, such as ALTER and so on.
Mysql > GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON dbname.tablename TO 'user1'@'192.168.155.1' IDENTIFIED BY' 123456'
Assign user user2 from 192.168.155.1 permission to perform all operations on all tables in the database dbname, and set the password to 123456.
Mysql > GRANT ALL PRIVILEGES ON dbname.* TO 'user2'@'192.168.155.1' IDENTIFIED BY' 123456'
Assign user user3 from 192.168.155.1 permission to perform all operations on all tables in all databases, and set the password to 123456.
Mysql > GRANT ALL PRIVILEGES ON *. * TO 'user3'@'192.168.155.1' IDENTIFIED BY' 123456'
Assign the local user user4 permissions to perform all operations on all tables in all databases and set the password to 123456.
Mysql > GRANT ALL PRIVILEGES ON *. * TO 'user4'@'localhost' IDENTIFIED BY' 123456'
Open external access to the firewall mysql3306 port
After CentOS was upgraded to 7, firewalld was used instead of iptables. Here is a record of how to use firewalld to open Linux ports
-- zone: scope. The network area defines the trust level of the network connection. This is an one-to-many relationship, which means that a connection can be only part of an area, and an area can be used for many connections.
-- add-port: add port and communication protocol. Format: Port / communication protocol. Protocol is tcp or udp.
-- permanent: permanent. Without this parameter, port access becomes invalid when the system is restarted.
[root@bogon /] # firewall-cmd-zone=public-add-port=3306/tcp-permanent
Restart the firewall
[root@bogon /] # firewall-cmd-- reload
How to change your root password after you forget it
Stop the mysql service, or command systemctl stop mysql
[root@bogon /] # service mysql stop
Enter / usr/local/mysql
[root@bogon /] # cd / usr/local/mysql/
Start mysql through mysqld_safe, and do not start the grant-tables authorization table when you start mysql
[root@bogon mysql] # / bin/mysqld_safe-- basedir=/usr/local/mysql\-- datadir=/usr/local/mysql/data\-- skip-grant-tables &
Log in to mysql
[root@bogon /] # mysql-u root mysql
Modify root password
Mysql > UPDATE user SET password=PASSWORD ("new_password") WHERE user='root'
Refresh
Mysql > FLUSH PRIVILEGES
Exit mysql
Mysql > exit
-
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.