In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Description: first of all, you must be able to link to the external network. If you cannot access it directly, you can also set up a proxy. Please refer to: setting a yum proxy on an intranet machine
The permission requirement for using yum is the root user. If you are not, you may need to add sudo before the shell command, or su root can switch to the super administrator for operation. And may need to enter a password.
1. Add yum data source
It is recommended that you name it something like MariaDB.repo:
[plain] view plain copy looks at the code chip derived from my code chip on CODE
Cd / etc/yum.repos.d/
Vim / etc/yum.repos.d/MariaDB.repo
Then, write the contents of the file: (10.0 is recommended)
[plain] view plain copy looks at the code chip derived from my code chip on CODE
# MariaDB 10.0 CentOS repository list-created 2015-08-12 10:59 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
Name = MariaDB
Baseurl = http://yum.mariadb.org/10.0/centos6-amd64
Gpgkey= https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Gpgcheck=1
The content of this file is referenced to the official website and generated from the official website. The specific address of the installation source warehouse is: https://downloads.mariadb.org/mariadb/repositories/.
After selecting the operating system version, you can view it, and the installation sources of other operating systems can also be viewed and set here.
If the server does not support https protocol, or if gpgkey guarantees errors and ensures that there is no problem, you can change gpgcheck=1 to gpgcheck=0 without verification.
My example:
[root@localhost ~] # cat / etc/yum.repos.d/MariaDB.repo
# MariaDB 10.1 CentOS repository list-created 2017-04-05 08:04 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
Name = MariaDB
Baseurl = http://yum.mariadb.org/10.1/centos6-amd64
Gpgkey= https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Gpgcheck=1
two。 Install the database
# yum remove MariaDB-server MariaDB-client
Yum-y install MariaDB-server MariaDB-client
If you want to delete the old database, you can use remove, the parameter-y is confirmation, do not prompt. Here, the server and client are installed, generally speaking, it is OK to install these two.
3. Start the database
If you don't need to do anything else, you can now start the database directly and test it.
# View mysql status; shut down the database
# service mysql status
# service mysql stop
# start the database
Service mysql start
4. Modify root password
# modify root password
Mysqladmin-u root password 'root'
Because the root password after installation is empty, it needs to be set; if it is a test server, you can use root directly, and the unimportant password can often be set to be the same as the user name, so as not to forget and forget.
If it is an important server, please use complex passwords, such as mailboxes, various free combination of regular characters, etc.
My example:
[root@localhost ~] # service mysql start
Starting MySQL.170405 17:20:34 mysqld_safe Logging to'/ var/lib/mysql/localhost.localdomain.err'.
170405 17:20:34 mysqld_safe Starting mysqld daemon with databases from / var/lib/mysql
[OK]
Root@localhost ~] # ps aux | grep mysq
Root 8824 0.0 11436 1564 pts/0 S 17:20 0:00 / bin/sh / usr/bin/mysqld_safe-- datadir=/var/lib/mysql-- pid-file=/var/lib/mysql/localhost.localdomain.pid
Mysql 8898 1.1 1.6 824048 134948 pts/0 Sl 17:20 0:00 / usr/sbin/mysqld-basedir=/usr-datadir=/var/lib/mysql-plugin-dir=/usr/lib64/mysql/plugin-user=mysql-log-error=/var/lib/mysql/localhost.localdomain.err-pid-file=/var/lib/mysql/localhost.localdomain.pid
5. Log into the database
Mysql-u root-p
If it is local, you can log in directly using the above command, of course, you need to enter a password. If it is another machine, you may need the following form:
Mysql-h 127.0.0.1-P 3306-u root-p
[root@localhost ~] # mysql
Welcome to the MariaDB monitor. Commands end with; or\ g.
Your MariaDB connection id is 3
Server version: 10.1.22-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
MariaDB [(none)] >
MariaDB [(none)] > show variables like 'innodb_file_per%'
+-+ +
| | Variable_name | Value |
+-+ +
| | innodb_file_per_table | ON |
+-+ +
1 row in set (0.00 sec)
6. Simple SQL test
-- check the status of MySQL
Status
-- display supported engines
Show engines
-- Show all databases
Show databases
-- switch the database context, that is, set the default database for the current session
Use test
-- display all tables in this database
Show tables
-- create a table
CREATE TABLE t_test (
Id int (11) UNSIGNED NOT NULL AUTO_INCREMENT
UserId char (36)
LastLoginTime timestamp
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
-- insert test data
Insert into t_test (userId)
Values
('admin')
, ('')
-- simple query
Select * from t_test
Select id,userId from t_test where userId='admin'
7. Modify the data storage directory
The default data of mysql and MariaDB is stored in the / var/lib/mysql/ directory. If you don't want to put it here, either you want the program to be separated from the data, or because of the disk.
If you need to switch to another path, you can do so by modifying the datadir system variable.
# stop the database
[root@localhost ~] # service mysql stop
Shutting down MySQL... [OK]
# create a directory, assuming there is no directory
[root@localhost] # mkdir-p / data/mysql
# set permissions
[root@localhost] # chown-R mysql:mysql / data/
[root@localhost ~] # ll / data/
Total 4
Drwxr-xr-x 5 mysql mysql 4096 Apr 5 17:50 mysql
# Reinitialize the database by following the command
[root@localhost] # / usr/bin/mysql_install_db-defaults-file=/etc/my.cnf.d/server.cnf-datadir=/data/mysql-user=mysql
# check whether data is generated under / data/mysql
[root@localhost ~] # ls / data/mysql/
Aria_log.00000001 bogon.err ib_logfile0 localhost.localdomain.err performance_schema
Aria_log_control ibdata1 ib_logfile1 mysql test
# in fact, if you look at the / etc/my.cnf file, you can find
There is only one containing statement in this file of # MariaDB
# so the configuration file that needs to be modified is / etc/my.cnf.d/server.cnf
Cp / etc/my.cnf.d/server.cnf / etc/my.cnf.d/server.cnf_original
Vim / etc/my.cnf.d/server.cnf
Then press I to enter edit mode, you can insert the relevant content. Use the keyboard keys around to move the cursor. When editing is finished, press ESC to exit editing mode (enter command mode), and then enter the command: wq save and exit
My example:
[root@localhost ~] # cat / etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in / usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
Datadir=/data/mysql # set / data/mysql to the data directory of the new file
Socket=/var/lib/mysql/mysql.sock
#
# * Galera-related settings
#
[galera]
# Mandatory settings
# wsrep_on=ON
# wsrep_provider=
# wsrep_cluster_address=
# binlog_format=row
# default_storage_engine=InnoDB
# innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
# bind-address=0.0.0.0
#
# Optional setting
# wsrep_slave_threads=1
# innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions
# use this group for options that older servers don't understand
[mariadb-10.1]
# restart MySQL
[root@localhost ~] # service mysql start
Starting MySQL.170405 17:50:20 mysqld_safe Logging to'/ data/mysql/localhost.localdomain.err'.
170405 17:50:20 mysqld_safe Starting mysqld daemon with databases from / data/mysql
[OK]
Tip:
/ usr/bin/mysqld_safe_helper: Can't create/write to file'/ data/mysql/bogon.err' (Errcode: 13 "Permission denied")
ERROR!
Hurt me, multi-party search to send selinx to open this, decisively disable, and then restart the operating system: OKcargo!
Vim / etc/sysconfig/selinux
SELINUX=disabled
[root@localhost ~] # mysql
Welcome to the MariaDB monitor. Commands end with; or\ g.
Your MariaDB connection id is 3
Server version: 10.1.22-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
MariaDB [(none)] > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | test |
+-+
4 rows in set (0.00 sec)
7.1 create a slow query log file
Since the slow log file is specified above, I later looked at the err log of MariaDB and found that MariaDB will not create the file on its own, so we need to create and modify the corresponding file permissions (for example, MySQL uses mysql users, maybe we use files created by root users, and the slow log files are required to be readable and writable to mysql users.)
Touch / usr/local/ieternal/mysql_data/slow_query_log.log
Chmod 666 / usr/local/ieternal/mysql_data/slow_query_log.log
Then restart MySQL.
Service mysql start
8. Initial setting of mysql
1. Delete anonymous users
Mysql > delete from mysql.user where user=''
2. Set the root password
1),
Mysqladmin-u root password "newpass"
2),
Mysql > SET PASSWORD FOR 'root'@'localhost' = PASSWORD (' newpass')
3),
Mysql > UPDATE mysql.user SET Password = PASSWORD ('db@pass123') WHERE user =' root'
Mysql > FLUSH PRIVILEGES
4) when you lose your root password, you can do this
Mysqld_safe-skip-grant-tables&
Mysql-u root mysql
Mysql > UPDATE user SET password=PASSWORD ("new password") WHERE user='root'
Mysql > FLUSH PRIVILEGES
Mysql > grant all on *. * to pancou@'%' identified by 'pancou'
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.