Mysql数据库自建,使用,问题排查最佳实践 Start main service ExecStart/mysql/install/mysql/bin/mysqld defaultsfile/mysql/install/my.cnf $MYSQLDOPTS Use this to switch malloc implementation EnvironmentFile/etc/sysconfig/mysql Sets openfileslimit LimitNOFILE 10000 Restartonfailure RestartPreventExitStatus1 Set environment variable MYSQLDPARENTPID. This is required for restart. EnvironmentMYSQLDPARENTPID1 PrivateTmpfalse [root@localhost system] systemctl enable mysqld.service Created symlink /etc/systemd/system/multiuser.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service. [root@localhost system] systemctl start mysqld.service [root@localhost system] systemctl status mysqld ● mysqld.service MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Tue 20241008 19:53:18 CST; 1s ago Docs: man:mysqld(8) Main PID: 4794 (mysqld) Status: "Server is operational" Tasks: 39 Memory: 422.6M CGroup: /system.slice/mysqld.service └─4794 /mysql/install/mysql/bin/mysqld defaultsfile/mysql/install/my.cnf Oct 08 19:53:10 localhost systemd[1]: Starting MySQL Server... Oct 08 19:53:18 localhost systemd[1]: Started MySQL Server. [root@localhost system] systemctl stop mysqld 自此mysql服务器自建完成。 mysql数据库基础使用介绍 mysql常用命令 查看mysql中有哪些数据库: plaintext mysql> show databases; 注意:以分号结尾,分号是英文的分号。 + Database + informationschema mysql performanceschema + 3 rows in set (0.02 sec) 选择使用某个数据库: plaintext mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with A Database changed 查看某个数据库下有哪些表: plaintext mysql> show tables; + Tablesinmysql + columnspriv component db defaultroles enginecost func generallog globalgrants gtidexecuted helpcategory helpkeyword helprelation helptopic innodbindexstats innodbtablestats ndbbinlogindex passwordhistory plugin procspriv proxiespriv replicationasynchronousconnectionfailover replicationasynchronousconnectionfailovermanaged replicationgroupconfigurationversion replicationgroupmemberactions roleedges servercost servers slavemasterinfo slaverelayloginfo slaveworkerinfo slowlog tablespriv timezone timezoneleapsecond timezonename timezonetransition timezonetransitiontype user + 创建数据库: plaintext mysql> create database example; Query OK, 1 row affected (0.01 sec) mysql> show databases; + Database + example informationschema mysql performanceschema + 4 rows in set (0.00 sec) 查看mysql数据库的版本号: plaintext mysql> select version(); + version() + 8.4.0 + 1 row in set (0.00 sec) 查看当前使用的是哪个数据库: plaintext mysql> select database(); + database() + mysql + 1 row in set (0.01 sec) 导入数据库表: plaintext mysql> source D:course03MySQLdocumenttest.sql