Mysql installation under Linux system

rpm -qa | grep -i mysql #If
installed, execute this line of code to delete the previously installed mysql
rpm -ev --nodeps mysql-libs-5.1.71-1.el6.x86_64

#Add user group mysql
groupadd mysql #Add
user mysql, join mysql user group
useradd -r -g mysql mysql    

#Install server
rpm -ivh MySQL-server-5.6.29-1.linux_glibc2.5.x86_64.rpm #Install
client
rpm -ivh MySQL-client-5.6.29-1.linux_glibc2.5.x86_64.rpm

====mysql5.6安装后所在的目录===========
Directory    Contents of Directory
/usr/bin    Client programs and scripts
/usr/sbin    The mysqld server
/var/lib/mysql    Log files, databases
/usr/share/info    MySQL manual in Info format
/usr/share/man    Unix manual pages
/usr/include/mysql    Include (header) files
/usr/lib/mysql    Libraries
/usr/share/mysql    Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation
/usr/share/sql-bench    Benchmarks
================================
#修改my.cnf,默认在/usr/my.cnf
vim /usr/my.cnf
    [client]
    default-character-set=utf8
    [mysql]
    default-character-set=utf8
    [mysqld]
    character_set_server=utf8
    # basedir = .....
    # datadir = .....
    # port = .....
    # server_id = .....
    # socket = .....
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    

#Add mysqld to the system service and randomly start
cp /usr/share/mysql/mysql.server /etc/init.d/mysqld

#The following two sentences are not needed!
#chkconfig --add mysqld
#chkconfig mysqld on 

#Start mysqld
service mysqld start

#Get the random password of the root user during mysql installation
vim /root/.mysql_secret 

#You must change the password of the root user to use mysql, otherwise you can only connect and cannot operate
mysqladmin -u root -p password root 

#Connect into mysql
mysql -u root -p
root

#View the installation and running path of
mysql ps -ef|grep mysql

Guess you like

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