Install mariadb from source

1. Unzip

tar zxvf  mariadb-5.5.31-linux-x86_64.tar.gz   
mv mariadb - 5.5 . 31 -linux-x86_64 /usr/local/mysql // Required, many scripts or executable programs will directly access this directory

2. Permissions

groupadd mysql              // Add mysql group 
useradd -g mysql mysql      // Add mysql user and belong to mysql group 
chown mysql:mysql -Rf /usr/local/mysql     // Set mysql directory user and user group ownership. 
chmod +x -Rf /usr/local/mysql     // Give executable permission

3. Copy the configuration file

cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf      // Copy the default mysql configuration file to the /etc directory

4. Initialization

/usr/local/mysql/scripts/mysql_install_db --user=mysql           // Initialize the database 
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql     // Copy the mysql service program to the system Directory 
chkconfig mysql on      // Add mysql to the system service and set it to start 
service mysql start   // Start mysql

5. Environment variable configuration

vim /etc/profile    // Edit profile, add the executable path of mysql to the system PATH 
export PATH=/usr/local/mysql/ bin:$PATH
source /etc/profile   // Make PATH take effect.

6. Account password

mysqladmin -u root password ' yourpassword '  // Set the root account and password 
mysql -u root -p   // Use the root user to log in to mysql 
use mysql   // Switch to the mysql database. 
select user,host,password from user; // View system permissions 
drop user '' @ ' localhost ' ; // Delete insecure accounts 
drop user root@ ' ::1 ' ;
drop user root@ 127.0 . 0.1 ;
 select user,host,password from user; // Check the system permissions again to ensure that insecure accounts are deleted. 
flush privileges;   // refresh privileges

7. Some necessary initialization configurations

1 ) Modify the character set to UTF8
vi / etc / my.cnfAdd default -character- set = utf8 
under [client]Add character_set_server = utf8
 2 
below [mysqld] ) increase error log
vi / etc / my.cnf
Add below [mysqld]:
log-error = /usr/local/mysql/log/error.log
general -log-file = /usr/local/mysql/log/ mysql.log
 3 ) is set to be case-insensitive, and it will be case-sensitive by default under linux.
vi / etc / my.cnf
Add below [mysqld]:
lower_case_table_name=1

Restart after modification: #service mysql restart

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325856969&siteId=291194637