【后端开发】配置mysql和postgresql

it2022-05-09  63

一、mysql配置

启动mysql服务器:service mysql start修改mySQL服务器密码:mysql -u root -p查看mysql服务器是否启动:service mysql statuslinux安装python包:apt install python-linux python2转到python3:安装django: pip install djangopython3没有MySQLdb,需要使用pymysql:pip install pymysqlservice mysql stop修改mySQL密码: update mysql.user set authentication_string=PASSWORD('123'), plugin='mysql_native_password' where user='root';flush privileges;python manage.py runserver编译数据库相关内容: g++ connectDB.cpp -o connectDB `mysql_config --cflags --libs`

二、 postgresql配置

1、linux系统

启动服务器:service postgresql start重启,查看状态,关闭:service postgresql restart/status/stop进入postgresql的管理系统,这里需要说明一下,在安装postgresql的时候,他会自动创建一个linux用户,其默认用户名为postgres。 所以我们要进入管理系统的话,首先我们的linux账户要切换到指定的账户下: su postgres,如果不成功试下这条sudo -i -u postgres然后在进入管理系统psql \c db连接到db数据库下\q退出管理系统。\l列出所有的数据库。修改默认用户的密码:alter user postgres with password 'postgres';

2、mac系统

安装:brew install postgresql卸载:brew uninstall postgresql 卸载的时候有可能出现某些文件夹权限不足的问题,可以使用如下方法解决:sudo chown -R $(whoami) /usr/local/lib 启动服务:brew services start postgresql创建数据库:createdb进入数据库管理系统:psql

最新回复(0)