折腾:
[未解决]SQLAlchemy中把sqlite换成mysql
期间,需要在CentOS中,创建好自己的数据库。
centos create mysql database
Create a MySQL Database on Linux via Command Line | Liquid Web Knowledge Base
A Basic MySQL Tutorial | DigitalOcean
How To Create a New User and Grant Permissions in MySQL | DigitalOcean
(SIPEvents) ➜ SIPEvents netstat -tupln Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:10022 0.0.0.0:* LISTEN 17286/docker-proxy tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 19706/docker-proxy tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 17220/mysqld tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 19659/redis-server tcp 0 0 0.0.0.0:9003 0.0.0.0:* LISTEN 19669/docker-proxy tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 16058/python tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 20416/nginx tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1335/sshd tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 17240/docker-proxy tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN 29962/docker-proxy tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 18421/docker-proxy tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 19505/docker-proxy tcp 0 0 0.0.0.0:32771 0.0.0.0:* LISTEN 8748/docker-proxy tcp 0 0 0.0.0.0:32772 0.0.0.0:* LISTEN 8782/docker-proxy udp 0 0 192.168.42.1:123 0.0.0.0:* 1346/ntpd udp 0 0 115.29.173.126:123 0.0.0.0:* 1346/ntpd udp 0 0 10.161.170.247:123 0.0.0.0:* 1346/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 1346/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 1346/ntpd |
->
后台有mysqld运行了
-》应该就是此处的CentOS中,已经安装了mysql的server了。
-》所以无需再去
yum install mysql-server
了。
Install a MySQL server on CentOS
且事实证明,此处已经安装了最新版的mysql的服务器了:
(SIPEvents) ➜ SIPEvents yum install mysql-server Loaded plugins: security Setting up Install Process base | 3.7 kB 00:00 centos-sclo-rh | 2.9 kB 00:00 elrepo | 2.9 kB 00:00 elrepo/primary_db | 716 kB 00:12 epel | 4.3 kB 00:00 epel/primary_db | 5.9 MB 00:05 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 2.0 MB 00:01 Package mysql-server-5.1.73-7.el6.x86_64 already installed and latest version Nothing to do |
mysql-server-5.1.73
(SIPEvents) ➜ SIPEvents mysql mysql mysqlcheck mysqldump mysqlhotcopy mysqlshow mysql_waitpid mysqlaccess mysql_config mysqldumpslow mysqlimport mysqlslap mysql_zap mysqladmin mysql_convert_table_format mysql_find_rows mysql_install_db mysqltest mysqlbinlog mysqld_multi mysql_fix_extensions mysql_secure_installation mysql_tzinfo_to_sql mysqlbug mysqld_safe mysql_fix_privilege_tables mysql_setpermission mysql_upgrade |
然后去登录,结果出错:
[已解决]CentOS中用root去登录mysql出错:ERROR 1045 28000 Access denied for user root@localhost using password NO
然后去创建数据库:
(SIPEvents) ➜ SIPEvents mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement. mysql> show tables; ERROR 1046 (3D000): No database selected mysql> show databases; +——————–+ | Database | +——————–+ | information_schema | | gogs | | mysql | | test | +——————–+ 4 rows in set (0.00 sec) mysql> create datebase sipevents; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘datebase sipevents’ at line 1 mysql> create database sipevents; Query OK, 1 row affected (0.00 sec) mysql> use sipevents; Database changed mysql> show tables; Empty set (0.00 sec) mysql> |
[总结]
去创建数据库,基本的步骤是:
1.登录mysql
mysql -u root -p 输入数据库的密码,回车,进入数据库 |
2.去创建数据库
create database sipevents; |
注:
1.查看当前有哪些数据库可以用:
show databases;
2.去看看新建的数据库中的表:
use sipevents; show tables; |
转载请注明:在路上 » [已解决]在CentOS中创建对应的mysql数据库