Correct command for installing mariadb on centos7
The centos7 System of linode is used, and mariadb is used by default when mysql is installed.
However, no matter whether you use the linode official website instructions or the basic installation method found by Baidu, the installation fails.
Always prompt this sentence:
ERROR2002 (HY000): Can 'tconnecttolocalmysqlserverthroughsocket '/var/lib/mysql. sock' (2)
Finally, google search for install mariadb on centos 7 to get the key step of installation.
Now that the installation is successful, please note the entire installation process:
[Php] view plaincopy
- Mysql: [root @ localhost ~] # Yum-yinstallmariadb *
- Loadedplugins: fastestmirror
- Loadingtransferspeedsfromcachedhostfile
- * Base: mirrors.linode.com
- * Extras: mirrors.linode.com
- * Updates: mirrors.linode.com
- ResolvingDependencies
- --> Runningtransactioncheck
- ---> Packagemariadb. x86_641: 5.5.37-1. el7_0willbeinstalled
- ---> Packagemariadb-bench.x86_641: 5.5.37-1. el7_0willbeinstalled
- ---> Packagemariadb-devel.x86_641: 5.5.37-1. el7_0willbeinstalled
- ---> Packagemariadb-embedded.x86_641: 5.5.37-1. el7_0willbeinstalled
- ---> Packagemariadb-embedded-devel.x86_641: 5.5.37-1. el7_0willbeinstalled
- ---> Packagemariadb-libs.x86_641: 5.5.37-1. el7_0willbeinstalled
- ---> Packagemariadb-server.x86_641: 5.5.37-1. el7_0willbeinstalled
- --> ProcessingDependency: perl-DBD-MySQLforpackage: 1: mariadb-server-5.5.37-1.el7_0.x86_64
- ---> Packagemariadb-test.x86_641: 5.5.37-1. el7_0willbeinstalled
- --> Runningtransactioncheck
- ---> Packageperl-DBD-MySQL.x86_640: 4.023-5. el7willbeinstalled
- --> FinishedDependencyResolution
- DependenciesResolved
- ========================================================== ========================================================== ======================================
- PackageArchVersionRepositorySize
- ========================================================== ========================================================== ======================================
- Installing:
- Mariadbx86_641: 5.5.37-1. el7_0updates8.9M
- Mariadb-benchx86_641: 5.5.37-1. el7_0updates385k
- Mariadb-develx86_641: 5.5.37-1. el7_0updates744k.
- Mariadb-embeddedx86_641: 5.5.37-1. el7_0updates3.6M.
- Mariadb-embedded-develx86_641: 5.5.37-1. el7_0updates7.4M.
- Mariadb-libsx86_641: 5.5.37-1. el7_0updates752k
- Mariadb-serverx86_641: 5.5.37-1. el7_0updates11M.
- Mariadb-testx86_641: 5.5.37-1. el7_0updates7.9M.
- Installingfordependencies:
- Perl-DBD-MySQLx86_644.023-5.el7base140k
- TransactionSummary
- ========================================================== ========================================================== ======================================
- Install8Packages (+ 1 Dependentpackage)
- Totaldownloadsize: 40 M
- Installedsize: 279 M
- Downloadingpackages:
- (1/9): mariadb-bench-5.5.37-1.el7_0.x86_64.rpm | small kb00: 00: 00
- (2/9): mariadb-devel-5.5.37-1.el7_0.x86_64.rpm | 744kB00: 00: 00
- (3/9): mariadb-embedded-5.5.37-1.el7_0.x86_64.rpm | 3.6MB00: 00: 00
- (4/9): mariadb-5.5.37-1.el7_0.x86_64.rpm | 8.9MB00: 00: 00
- (5/9): mariadb-libs-5.5.37-1.el7_0.x86_64.rpm | 752kB00: 00: 00
- (6/9): mariadb-server-5.5.37-1.el7_0.x86_64.rpm | 11MB00: 00: 00
- (7/9): mariadb-embedded-devel-5.5.37-1.el7_0.x86_64.rpm | 7.4MB00: 00: 00
- (8/9): mariadb-test-5.5.37-1.el7_0.x86_64.rpm | 7.9MB00: 00: 00
- (9/9): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm | 140kB00: 00: 00
- Bytes ----------------------------------------------------------------------------------------------------------
- Total36MB/s | 40MB00: 00: 01
- Runningtransactioncheck
- Runningtransactiontest
- Transactiontestsucceeded
- Runningtransaction
- Installing: 1: mariadb-libs-5.5.37-1.el7_0.x86_641/9
- Installing: 1: mariadb-5.5.37-1.el7_0.x86_642/9
- Installation: perl-DBD-MySQL-4.023-5.el7.x86_643/9
- Installing: 1: mariadb-server-5.5.37-1.el7_0.x86_644/9
- Installing: 1: mariadb-devel-5.5.37-1.el7_0.x86_645/9
- Installing: 1: mariadb-embedded-5.5.37-1.el7_0.x86_646/9
- Installing: 1: mariadb-embedded-devel-5.5.37-1.el7_0.x86_647/9
- Installing: 1: mariadb-test-5.5.37-1.el7_0.x86_648/9
- Installing: 1: mariadb-bench-5.5.37-1.el7_0.x86_649/9
- Verifying: 1: mariadb-test-5.5.37-1.el7_0.x86_641/9
- Verifying: 1: mariadb-embedded-devel-5.5.37-1.el7_0.x86_642/9
- Verifying: 1: mariadb-embedded-5.5.37-1.el7_0.x86_643/9
- Verifying: 1: mariadb-libs-5.5.37-1.el7_0.x86_644/9
- Verifying: 1: mariadb-bench-5.5.37-1.el7_0.x86_645/9
- Verifying: 1: mariadb-5.5.37-1.el7_0.x86_646/9
- Verifying: 1: mariadb-server-5.5.37-1.el7_0.x86_647/9
- Verifying: perl-DBD-MySQL-4.023-5.el7.x86_648/9
- Verifying: 1: mariadb-devel-5.5.37-1.el7_0.x86_649/9
- Installed:
- Mariadb. x86_641: 5.5.37-1. el7_0mariadb-bench.x86_641: 5.5.37-1. el7_0
- Mariadb-devel.x86_641: 5.5.37-1. el7_0mariadb-embedded.x86_641: 5.5.37-1. el7_0
- Mariadb-embedded-devel.x86_641: 5.5.37-1. el7_0mariadb-libs.x86_641: 5.5.37-1. el7_0
- Mariadb-server.x86_641: 5.5.37-1. el7_0mariadb-test.x86_641: 5.5.37-1. el7_0
- DependencyInstalled:
- Perl-DBD-MySQL.x86_640: 4.023-5. el7
- Complete!
- [Root @ localhost ~] # Systemctlstartmariadb. service
- [Root @ localhost ~] # Systemctlenablemariadb. service
- Ln-s '/usr/lib/systemd/system/mariadb. service'/etc/systemd/system/multi-user.target.wants/mariadb. servi
- Ce'
- [Root @ localhost ~] # Mysql
- WelcometotheMariaDBmonitor. Commandsendwith; or \ g.
- YourMariaDBconnectionidis2
- Serverversion: 5.5.37-MariaDBMariaDBServer
- Copyright (c) 2000,2014, Oracle, MontyProgramAbandothers.
- Type 'help; 'or' \ H' forhelp. Type '\ C' toclearthur ecurrentinputstatement.
- MariaDB [(none)]> logout
- -> Exit
- ->
- ->;
- ERROR1064 (42000): YouhaveanerrorinyourSQLsyntax; checkthemanualthatcorrespondstoyourMariaD
- Bserverversionfortherightsyntaxtousenear 'logout
- Exit 'atline1
- MariaDB [(none)]> exit
- Bye
- [Root @ localhost ~] # Systemctlenablemariadb. service
- [Root @ localhost ~] # Mysql
- WelcometotheMariaDBmonitor. Commandsendwith; or \ g.
- YourMariaDBconnectionidis3
- Serverversion: 5.5.37-MariaDBMariaDBServer
- Copyright (c) 2000,2014, Oracle, MontyProgramAbandothers.
- Type 'help; 'or' \ H' forhelp. Type '\ C' toclearthur ecurrentinputstatement.
- MariaDB [(none)]> showdatabases;
- + -------------------- +
- | Database |
- + -------------------- +
- | Information_schema |
- | Mysql |
- | Performance_schema |
- | Test |
- + -------------------- +
- 4 rowsinset (0.00sec)
- MariaDB [(none)]> usetest
- Databasechanged
- MariaDB [test]> showtables;
- Emptyset (0.00sec)
- MariaDB [test]> exit
- Bye
- [Root @ localhost ~] # Mysql_secure_installation
- /Usr/bin/mysql_secure_installation: line379: find_mysql_client: commandnotfound
- NOTE: RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDB
- SERVERSINPRODUCTIONUSE! PLEASEREADEACHSTEPCAREFULLY!
- Inordertologtailmariadbtosecureit, we 'llneedthecurrent
- Passwordfortherootuser. Ifyou 'vejustinstalledmariadb, and
- Youhaven 'tsettherootpasswordyet, thepasswordwillbeblank,
- Soyoushouldjustpressenterhere.
- ERROR1045 (28000): Accessdeniedforuser 'root' @ 'localhost' (usingpassword: YES)
- Entercurrentpasswordforroot (enterfornone ):
- OK, successfullyusedpassword, movingon...
- Settingtherootpasswordensuresthatnobodycanlog=themariadb
- Rootuserwithouttheproperauthorisation.
- Setrootpassword? [Y/n] y
- Newpassword:
- Re-enternewpassword:
- Passwordupdatedsuccessfully!
- Reloadingprivilegetables ..
- ... Success!
- Bydefault, amariadbinstallationhasanonymoususer, allowinganyone
- Tologtailmariadbwithouthavingtohaveauseraccountcreatedfor
- Them. Thisisintendedonlyfortesting, andtomaketheinstallation
- Goabitsmoother. youshouldremovethembeforemovingtransfera
- Productionenvironment.
- Removeanonymoususers? [Y/n] y
- ... Success!
- Normally, rootshouldonlybeallowedtoconnectfrom 'localhost'. This
- Ensuresthatsomeonecannotguessattherootpasswordfromthenetwork.
- Disallowrootloginremotely? [Y/n] y
- ... Success!
- Bydefault, MariaDBcomeswithadatabasenamed 'test' thatanyonecan
- Access. Thisisalsointendedonlyfortesting, andshouldberemoved
- Beforemovingpaiaproductionenvironment.
- Removetestdatabaseandaccesstoit? [Y/n] y
- -Droppingtestdatabase...
- ... Success!
- -Removingprivilegesontestdatabase...
- ... Success!
- Reloadingtheprivilegetableswillensurethatallchangesmadesofar
- Willtakespontimmediately.
- Reloadprivilegetablesnow? [Y/n] y
- ... Success!
- Cleaningup...
- Alldone! Ifyou 'vecompletedalloftheabovesteps, yourMariaDB
- Installationshouldnowbesecure.
- ThanksforusingMariaDB!
- [Root @ localhost ~] # Mysql-uroot-p
- Enterpassword:
- WelcometotheMariaDBmonitor. Commandsendwith; or \ g.
- YourMariaDBconnectionidis15
- Serverversion: 5.5.37-MariaDBMariaDBServer
- Copyright (c) 2000,2014, Oracle, MontyProgramAbandothers.
- Type 'help; 'or' \ H' forhelp. Type '\ C' toclearthur ecurrentinputstatement.
- MariaDB [(none)]> showdatabases;
- + -------------------- +
- | Database |
- + -------------------- +
- | Information_schema |
- | Mysql |
- | Performance_schema |
- | Zbphp.com |
- + -------------------- +
- 4 rowsinset (0.00sec)
- MariaDB [(none)]>
Article by default7 # zbphp.com