应用服务器:
1、redhat版本查看:
本应用服务器:Red Hat Enterprise Linux Server release 7.6 (Maipo)
查看linux的版本主要有三种方法:
- 登录到服务器执行 lsb_release -a ,即可列出所有版本信息,例如:
[root@3.5.5Biz-46 ~]# lsb_release -a
LSB Version: 1.3
Distributor ID: RedHatEnterpriseAS
Description: Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
Release: 4
Codename: NahantUpdate1
[root@3.5.5Biz-46 ~]#
这个命令适用于所有的linux,包括Redhat、SuSE、Debian等发行版。
- 登录到linux执行cat /etc/redhat-release ,例如如下:
[root@3.5.5Biz-46 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 1)
[root@3.5.5Biz-46 ~]#
这种方式下可以直接看到具体的版本号,比如 AS4 Update 1
3)登录到linux执行rpm -q redhat-release ,例如如下
[root@3.5.5Biz-46 ~]# rpm -q redhat-release
redhat-release-4AS-2.4
[root@3.5.5Biz-46 ~]#
这种方式下可看到一个所谓的release号,比如上边的例子是2.4
这个release号和实际的版本之间存在一定的对应关系,如下:
redhat-release-3AS-1 -> Redhat Enterprise Linux AS 3
redhat-release-3AS-7.4 -> Redhat Enterprise Linux AS 3 Update 4
redhat-release-4AS-2 -> Redhat Enterprise Linux AS 4
redhat-release-4AS-2.4 -> Redhat Enterprise Linux AS 4 Update 1
redhat-release-4AS-3 -> Redhat Enterprise Linux AS 4 Update 2
redhat-release-4AS-4.1 -> Redhat Enterprise Linux AS 4 Update 3
redhat-release-4AS-5.5 -> Redhat Enterprise Linux AS 4 Update 4
注意:第(2)(3)两种方法只对Redhat Linux有效
2、python3安装
https://www.python.org/ftp/python/ 下载Python-3.7.9.tgz
解压
tar -zxvf Python-3.7.9.tgz
进入解压后的目录,依次执行下面命令进行手动编译,最后没提示出错,就代表正确安装了,在/usr/local/目录下就会有Python-3.7.9目录
cd Python-3.7.9
./configure --enable-optimizations --prefix=/usr/local/python-3.7.9
make && make install
make install报错:
/usr/bin/install: cannot create directory ‘/usr/local/python-3.7.9’: Permission denied
make: *** [install] Error 1
解决:
切换为root :su root
输入root密码
然后在执行 : 先执行make clean
在执行 make && make install
make install报错:
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
问题分析
从错误信息分析,就是缺少了zlib的解压缩类库,安装即可
yum -y install zlib*
添加python3的软链接
ln -s /usr/local/python-3.7.9/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python-3.7.9/bin/pip3.7 /usr/bin/pip3
测试是否安装成功了
python3 -V
下离线安装python项目的依赖包
3、nginx安装
安装yum依赖包
下载依赖包:
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-54.el7_8.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-cron-3.4.3-168.el7.centos.noarch.rpm
安装:
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum*
安装过程:
[root@localhost soft]# rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
warning: python-iniparse-0.4-9.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
package python-iniparse-0.4-9.el7.noarch is already installed
file /usr/lib/python2.7/site-packages/iniparse/ini.pyc from install of python-iniparse-0.4-9.el7.noarch conflicts with file from package python-iniparse-0.4-9.el7.noarch
file /usr/lib/python2.7/site-packages/iniparse/ini.pyo from install of python-iniparse-0.4-9.el7.noarch conflicts with file from package python-iniparse-0.4-9.el7.noarch
[root@localhost soft]# rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
warning: yum-metadata-parser-1.1.4-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
package yum-metadata-parser-1.1.4-10.el7.x86_64 is already installed
file /usr/lib64/python2.7/site-packages/_sqlitecache.so from install of yum-metadata-parser-1.1.4-10.el7.x86_64 conflicts with file from package yum-metadata-parser-1.1.4-10.el7.x86_64
安装Nginx
wget http://nginx.org/download/nginx-1.20.1.tar.gz
tar -zxvf nginx-1.20.1.tar.gz
cd nginx-1.20.1
./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-pcre \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_image_filter_module \
--with-http_slice_module \
--with-mail \
--with-threads \
--with-file-aio \
--with-stream \
--with-mail_ssl_module \
--with-stream_ssl_module
或
#./configure --help 查看常用模块
./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-http_perl_module \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-http_addition_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module
make && make install
/usr/local/nginx
常见错误:
- 错误为:
./configure: error: the HTTP rewrite module requires the PCRE library.
解决方案:安装 pcre-devel(系统自带)
yum -y install pcre-devel
- Nginx 编译报错:
SSL modules require the OpenSSL library
解决方案:yum -y install openssl openssl-devel
- Nginx 编译报错
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
解决方案:yum install gd gd-devel
或 yum -y install gd-devel
- Nginx 编译报错./configure: error: perl module ExtUtils::Embed is
required
解决方法:
yum -y install perl-devel perl-ExtUtils-Embed
- nginx -t命令测试时候报错
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: [emerg] getpwnam("nginx") failed
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
创建一个nginx用户
useradd -s /sbin/nologin -M nginx
实际用下面方法:
nginx编译安装之后,启动出现了:nginx: [emerg] getpwnam(“nginx”) failed
这个是因为我编译安装nginx的时候指定了–user=nginx和–group=nginx
解决方法
useradd nginx
[root@localhost sbin]# useradd nginx
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost sbin]#
验证配置文件是否正确
./nginx -t
重启nginx : ./nginx -s reload
停止nginx : ./nginx -s stop
查看是否安装成功,出现版本号就是成功 : ./nginx -v
查看是否启动 : netstat -ntlp |grep nginx
在加载nginx配置文件时,报错nginx: [error] invalid PID number ; in /usr/local/nginx/logs/nginx.pid
1.nginx 重新加载命令./nginx -s reload
,出现
nginx: [error] invalid PID number “” in "/usr/local/nginx/logs/nginx.pid"问题。
解决办法:
1、执行命令 killall -9 nginx 杀掉nginx 进程
2、进入 目录 cd /usr/local/nginx
3、执行命令 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (根据实际安装路径修改)
重新加载配置文件
4、进入 /usr/local/nginx/sbin
5、执行命令 ./nginx -s reload 重新启动nginx
6、重新启动nginx
./nginx 启动
./nginx -s stop 关闭ls
./nginx -s reload 重启
启动项目: python3 manage.py runserver 127.0.0.1:8000(如果是服务器或虚拟机安装,把 127.0.0.1:8000 改成 0.0.0.0:8000)
python3 manage.py runserver 0.0.0.0:8000
.env文件无法传输到Linux机器上
因为.开头的文件在linux系统中是不显示的,可以用过ls -a命令进行查看,发现.开头的文件其实都有传输成功
用压缩包上传总应用程序,不容易卡死
然后解压
unzip -o -d /home/agrj/ django-vue-admin-master.zip
chmod 777 /home/agrj/django-vue-admin-master
chmod 777 /usr/local/nginx/conf/nginx.conf
python-django项目迁移依赖包离线安装
1.在项目中导出下载依赖包包:
pip freeze > requirements.txt
导出环境中用到的依赖包记录文本
#pip download -d /tmp/packages -r requirements.txt
pip download -d E:\PROGRAM\django-vue-admin-master\dvadmin-backend\bao -r requirements.txt
要保存下载的包的目录 -r requirements.txt 通过txt文件中的内容,下载相应的依赖包到指定目录
2.通过上面的方法,把包拷贝到内网服务器
3.安装包:
#/home/agrj/soft/
pip install --no-index --find-links=packages -r requirements.txt
pip3 install --no-index --find-links=packages -r requirements.txt
安装不上如:
ERROR: Could not find a version that satisfies the requirement pymongo<4.0,>=3.4 (from mongoengine==0.22.1->-r requirements.txt (line 39)) (from versions: none)
ERROR: No matching distribution found for pymongo<4.0,>=3.4 (from mongoengine==0.22.1->-r requirements.txt (line 39))
可以改whl文件名后缀为-py3-none-any.whl
pip3 install --no-index --find-links=packages -r requirements.txt
(requirements.txt 和packages文件夹同目录下)
也可以下载一个包后,通过pip install **.whl
或者python setup.py install **.tar.gz
安装指定安装目录
pip3 install --no-index --find-links=packages -r requirements.txt --target=/opt/envs/django2.1.8/lib/python3.8/site-packages
#未测试
4. 注意:python3不再支持mysqldb,取而代之的是pymysql,安装依赖包时应注意。
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
在pip安装过程中,
ModuleNotFoundError: No module named ‘_ctypes‘解决方法
解决方案
其实很简单安装一下外部函数库(libffi)就可以了,操作步骤如下:
1、yum install libffi-devel -y
2、源码安装的python3 重新编译安装, 如果通过yum安装的 那么直接执行命令 yum install python
./configure --prefix=/usr/local/python3
make && make install
如果遇到ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
执行以下命令即可解决
pip install --user pytest-runner pip3 install --user pytest-runner
(经测试需要联网)
安装uwsgi:
官网下载页 https://uwsgi-docs.readthedocs.io/en/latest/Download.html 选择版本下载
如果打开网速较慢,可以尝试此链接,最后的版本号根据自己需求修改并建立下载任务,此处我选择的是2.0.18的版本,所以链接地址是 https://projects.unbit.it/downloads/uwsgi-2.0.18.tar.gz
/home/agrj/django-vue-admin-master/dvadmin-backend/
解压安装(注意使用root用户安装)
将下载好的安装包上传到服务器 /usr/local 文件夹下
chmod 777 /usr/local/
cd /usr/local
# 进入安装目录
tar zxvf uwsgi-2.0.18.tar.gz
# 解压文件夹
cd uwsgi-2.0.18
make
make失败:plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory #include <Python.h> ^
解决办法
尝试安装以下的包
yum install python-devel.x86_64
yum install python3-devel.x86_64
chmod 755 /usr/local/
启动 uwsgi --ini application/uwsgi.ini
uwsgi --ini uwsgi.ini
报错uwsgi: command not found
解决办法:找到uwsgi执行位置,建立软链接
[root@localhost home]# find / -name uwsgi
/usr/bin/uwsgi
/usr/local/uwsgi-2.0.18/bin/uwsgi
/usr/local/uwsgi-2.0.18/ext/uwsgi
/usr/local/uwsgi-2.0.18/t/ring/src/uwsgi
/usr/local/uwsgi-2.0.18/uwsgi
ln -s /usr/local/uwsgi-2.0.18/bin/uwsgi /usr/bin/uwsgi
[root@localhost uwsgi-2.0.18]# ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
ln: failed to create symbolic link ‘/usr/bin/uwsgi’: File exists
#解决方法:删除软连接
[root@localhost uwsgi-2.0.18]# rm /usr/bin/uwsgi
rm: remove symbolic link ‘/usr/bin/uwsgi’? y
[root@localhost uwsgi-2.0.18]# ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
成功连接但uwsgi不管用
python3 setup.py --build
方法2:安装uwsgi,不用make
/home/agrj/soft
[root@localhost soft]# pip3 install uwsgi-2.0.18.tar.gz
Processing ./uwsgi-2.0.18.tar.gz
Using legacy setup.py install for uWSGI, since package 'wheel' is not installed.
Installing collected packages: uWSGI
Running setup.py install for uWSGI ... done
Successfully installed uWSGI-2.0.18
[root@localhost soft]#
ln -s /usr/local/python-3.7.9/bin/uwsgi /usr/bin/uwsgi
[root@localhost soft]# uwsgi --version
bash: uwsgi --version: command not found
[root@localhost soft]# find / -name uwsgi
/usr/bin/uwsgi
/usr/local/python-3.7.9/bin/uwsgi
/usr/local/uwsgi-2.0.18/bin/uwsgi
/usr/local/uwsgi-2.0.18/ext/uwsgi
/usr/local/uwsgi-2.0.18/t/ring/src/uwsgi
[root@localhost soft]# ln -s /usr/local/python-3.7.9/bin/uwsgi /usr/bin/uwsgi
ln: failed to create symbolic link ‘/usr/bin/uwsgi’: File exists
[root@localhost soft]# rm /usr/bin/uwsgi
rm: remove symbolic link ‘/usr/bin/uwsgi’? y
[root@localhost soft]# find / -name uwsgi
/usr/local/python-3.7.9/bin/uwsgi
/usr/local/uwsgi-2.0.18/bin/uwsgi
/usr/local/uwsgi-2.0.18/ext/uwsgi
/usr/local/uwsgi-2.0.18/t/ring/src/uwsgi
[root@localhost soft]# ln -s /usr/local/python-3.7.9/bin/uwsgi /usr/bin/uwsgi
[root@localhost soft]# find / -name uwsgi
/usr/bin/uwsgi
/usr/local/python-3.7.9/bin/uwsgi
/usr/local/uwsgi-2.0.18/bin/uwsgi
/usr/local/uwsgi-2.0.18/ext/uwsgi
/usr/local/uwsgi-2.0.18/t/ring/src/uwsgi
[root@localhost soft]# whereis uwsgi
uwsgi: /usr/bin/uwsgi
清除rm /usr/local/uwsgi-2.0.18/bin/uwsgi
启动 uwsgi --ini application/uwsgi.ini
成功
启动中间有错误 用sqlsever缺少东西太多连接不上
改为用mysql
启动中间有错误python 3.7 cannot import name ‘_mysql’ from ‘MySQLdb’ (
[root@localhost dvadmin-backend]# cd /home/agrj/soft/packages
[root@localhost packages]# pip3 install PyMySQL-1.0.2-py3-none-any.whl
Processing ./PyMySQL-1.0.2-py3-none-any.whl
Installing collected packages: PyMySQL
Successfully installed PyMySQL-1.0.2
ImportError: cannot import name '_imaging' from 'PIL'
python3 setup.py install Pillow-4.0.0.tar.gz
/home/agrj/soft/packages
/usr/local/python-3.7.9/lib/python3.7/site-packages
联网后pip3 install 报错
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f70c8bfaf50>: Failed to establish a new connection: [Errno -2] Name or service not known')':
可能是DNS未配置
配置办法:介绍一种
打开文件
sudo vim /etc/resolv.conf
插入以下两句
nameserver 8.8.8.8
nameserver 114.114.114.114
保存(不需要重启网络或服务器)
更改文件权限可以记事本修改
root@localhost agrj]# chmod 777 /etc/resolv.conf
[root@localhost agrj]# chmod 664 /etc/resolv.conf
启动网站时
ImportError: cannot import name '_psutil_linux' from 'psutil' (/usr/local/python-3.7.9/lib/python3.7/site-packages/psutil/__init__.py)
[root@localhost dvadmin-backend]# pip3 install psutil
Requirement already satisfied: psutil in /usr/local/python-3.7.9/lib/python3.7/site-packages (5.8.0)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
卸载psutil
[root@localhost dvadmin-backend]# pip3 uninstall psutil
在线重新安装对应版本psutil
[root@localhost dvadmin-backend]# pip3 install psutil
File "/usr/local/python-3.7.9/lib/python3.7/site-packages/django/db/backends/mysql/operations.py", line 146, in last_executed_query
query = query.decode(errors='replace')
AttributeError: 'str' object has no attribute 'decode'
解决办法:打开此文件把146行的decode修改为encode
启动后端
[root@localhost django-vue-admin-master]# cd /home/agrj/django-vue-admin-master/dvadmin-backend
[root@localhost dvadmin-backend]# python3 manage.py makemigrations
No changes detected
[root@localhost dvadmin-backend]# python3 manage.py migrate
[root@localhost dvadmin-backend]# python3 manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
[2022-12-16 10:16:24][django.utils.autoreload.run_with_reloader():597] [INFO] Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
December 16, 2022 - 10:16:25
Django version 2.2.16, using settings 'application.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
安装npm
npm 不需要单独安装。在安装 Node 的时候,会连带一起安装 npm 。但是,Node 附带的 npm 可能不是最新版本,最后用下面的命令,更新到最新版本。
#sudo npm install npm -g
安装nodejs
1、采用解压方式进行安装,安装步骤如下:
1)下载
在http://nodejs.cn/download/下进行下载,选择自己的平台。
这里是x64,下载安装包node-v8.6.0-linux-x64.tar.xz
**注意事项:**通过命令uname -m&&uname -r查看系统版本,是x86还是x64平台。如果安装包与系统不符,则会抛错:/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
2)将文件下载或拷贝至/usr/local/src
目录下,可使用xshell
工具上传文件
3)解压
cd /usr/local/src
tar xvf node-v16.18.1-linux-x64.tar.xz
4)配置
vi /etc/profile
vi使用{vi是打开文件后的命令模式状态。 您可以使用i或a命令进入可编辑状态。 在这里我按a进入编辑模式。
在编辑模式的情况下,您应该在此时保存文件。 要保存文件,请按esc,这将返回vi的命令模式。
按esc后,输入冒号(英文),然后切换到最后一行模式,最后一行模式决定是否保存文件。
在最后一行模式中,您可以通过按x进行保存,x命令 :x可以保存已编辑的文件。
你也可以用wq保存。
然后检查以查看使用的cat文件名。
可以看到vi写的内容,表示保存成功。}
在最下面加入
#node (注释作用)
export NODE_HOME=/usr/local/src/node-v16.18.1-linux-x64
export NODE_PATH=$NODE_HOME/lib/node_modules
export PATH=$PATH:$NODE_HOME/bin
5)使配置文件生效:
source /etc/profile
6)测试是否安装成功
使用 node -v,显示版本号则安装成功
[root@localhost bin]# ./node -v
v16.18.1
[root@localhost bin]# ./npm -v
/usr/bin/env: node: No such file or directory
[root@localhost bin]# ln -s /usr/local/node-v16.18.1-linux-x64/bin/node /usr/local/bin/
[root@localhost bin]# ln -s /usr/local/node-v16.18.1-linux-x64/bin/npm /usr/local/bin/
[root@localhost bin]# node -v
v16.18.1
[root@localhost bin]# npm -v
8.19.2
[root@localhost bin]# ./node -v
v16.18.1
[root@localhost bin]# ./npm -v
8.19.2
[root@localhost bin]#
###########################
解压:tar -xvf node-v16.18.1-linux-x64.tar.xz
改目录名:
mv /usr/local/node-v16.18.1-linux-x64 /usr/local/node
mv命令用来修改名字或移动文件的
查看版本(./代表从当前目录找)
./node -v
./npm -v(需要配环境变量)
配环境变量
vi /etc/profile
最后加上这句话:export PATH=$PATH:/usr/local/node/bin
让新加的配置生效:source /etc/profile
配软连接:
相当于全局变量,在任何文件夹都能查看版本信息
ln -s /usr/local/node/bin/node /usr/local/bin/
ln -s /usr/local/node/bin/npm /usr/local/bin/
###########################
2、源码编译安装
cd /usr/local/src
wget https://npmmirror.com/mirrors/node/v16.18.1/node-v16.18.1.tar.gz
tar zxvf node-v16.18.1.tar.gz
cd node-v16.18.1
./configure
make
make install
常用路径(根据自己项目路径不同):
/home/agrj/django-vue-admin-master/dvadmin-backend
/home/agrj/django-vue-admin-master/dvadmin-ui
G:\tools\python\redhat7.6配置包
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -s start
/usr/local/nginx/sbin/nginx -s reload
数据库服务器:
安装sql server 2016;
注意事项:
1、报错项目不要选择安装如R 什么的。
2、打开防火墙设置——>高级设置,选择左侧的入站规则,然后点击右侧新建规则 添加1433端口
django.core.exceptions.ImproperlyConfigured: ‘sql_server.pyodbc’ isn’t an available database backend.
pip install django-pyodbc-azure
未能执行数据库迁移(数据库安装成了但django连不上)
mysql安装:
错误1:
C:\Users\Administrator>C:\mysql\mysql-8.0.31-winx64\bin
'C:\mysql\mysql-8.0.31-winx64\bin' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
解决:
C:\mysql-8.0.31>cd C:\mysql-8.0.31\bin
C:\mysql-8.0.31\bin>mysqld --initialize --console
2022-12-13T00:40:55.916493Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-12-13T00:40:55.916539Z 0 [System] [MY-013169] [Server] C:\mysql-8.0.31\bin\mysqld.exe (mysqld 8.0.31) initializing of server in progress as process 4928
2022-12-13T00:40:55.918231Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2022-12-13T00:40:55.932941Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-12-13T00:40:56.599705Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-12-13T00:40:57.705272Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: a!RsgW#mi9Ji
C:\mysql-8.0.31\bin>
密码 root@localhost: a!RsgW#mi9Ji
//安装mysql服务并启动
C:\mysql\mysql-8.0.31-winx64\bin>mysqld -install
Service successfully installed.
C:\mysql-8.0.31\bin>mysqld --install mysql
Service successfully installed.
C:\mysql\mysql-8.0.31-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
//修改密码为x@mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'x@mysql';
//查看到端口号
show global variables like 'port';
*错误2:Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理*
1、连接服务器: mysql -u root -p
2、看当前所有数据库:show databases;
3、进入mysql数据库:use mysql;
4、查看mysql数据库中所有的表:show tables;
5、查看user表中的数据:select Host, User,Password from user;
6、修改user表中的Host:update user set Host=‘%’ where User=‘root’;
方法1:update user set host = ‘%’ where user =‘root’;
方法2:
GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ IDENTIFIED BY ‘w123318’ WITH GRANT OPTION;
一种情况mysql的赋权操作:GRANTALLPRIVILEGESON*.*TOroot@%IDENTIFIEDBY123456WITHGRANTOPTION;mysql赋权操…
一种情况
mysql的赋权操作:GRANT ALL PRIVILEGES ON . TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
mysql赋权操作:
GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
flush privileges;
GRANT:赋权命令
ALL PRIVILEGES:当前用户的所有权限
ON:介词
.:当前用户对所有数据库和表的相应操作权限
TO:介词
‘root’@’%’:权限赋给root用户,所有ip都能连接
IDENTIFIED BY ‘123456’:连接时输入密码,密码为123456
WITH GRANT OPTION:允许级联赋权
20200901:
将GRANT语句通过代码块包起来
二种情况
mysql中远程连接权限语句grant all privileges on .VawFYbXAcO to ‘root‘@‘%‘ identified by ‘123456‘ with grant optio报错
grant all privileges on . tojavascript ‘root‘@‘%‘ identified by ‘123456‘ with grant option
原因: mysql的版本问题,这条语句适用于MySQL8.0之前
解决: mysql8.0及以上版本需要使用以下语句:
create user root@'%' identified by '123456';
grant all privileges on *.* to root@'%' with grant option;
到此这篇关于mysql的赋权操作:GRANT ALL PRIVILEGES ON . TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;的文章就介绍到这了,更多相关mysql的赋权操作:GRANT ALL PRIVILEGES ON . TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
7、最后刷新一下:flush privileges;
#一定要记得在写sql的时候要在语句完成后加上" ; "下面是图示说明
D:MySqlin>mysqld --install "MySql80" --defaults-file="C:/mysql/mysql-8.0.31-winx64/my.ini"