我正在写一个python3脚本来自动安装radius和daloradius。 在中间,我得到一些错误。我的代码是:
import subprocess
import os
import sys
# Updating Resources
os.system("sudo apt-get update -y")
#subprocess.call(["apt-get", "install", "freeradius"])
#Installing Radius & Dependencies
print("\n Installing Free Radius ... \n")
os.system("sudo apt-get install freeradius freeradius-mysql -y")
print("\nInstalling LAMP ... \n")
os.system("sudo apt-get install mysql-server mysql-client apache2 php5 libapache2-mod-php5 php5-mysql php5-common php5-gd php-pear php-db php-mail -y")
#os.system("sudo apt-get install python-dev libmysqlclient-dev python3-pip")
#os.system("sudo pip3 install mysqlclient")
#Creating A Database for radius server
os.system("mysql -h localhost -uroot -p123 -e 'CREATE DATABASE foo';")
os.system("mysql -h localhost -uroot -p123 -e 'CREATE USER 'radius2'@'localhost' IDENTIFIED BY 'radpass'';")
os.system("mysql -h localhost -uroot -p123 -e 'GRANT ALL PRIVILEGES ON `radius` . * TO 'radius2'@'localhost'';")
我在收到一个错误
^{pr2}$错误是:
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 'radpass' at line 1
SQL语句中有两个多个单引号,请使用反斜杠对它们进行转义:
您只能使用一个语句创建用户并向其授予权限:
^{pr2}$相关问题 更多 >
编程相关推荐