如何编写脚本在 Ubuntu 上安装 MySQL 服务器?
How do I write a script to install MySQL server on Ubuntu?
sudo apt-get install mysql 会安装,但也会要求在控制台输入密码.
sudo apt-get install mysql will install, but it will also ask for a password to be entered in the console.
如何以非交互式方式执行此操作?也就是写个脚本可以提供密码?
How do I do this in a non-interactive way? That is, write a script that can provide the password?
#!/bin/bash
sudo apt-get install mysql # To install MySQL server
# How to write script for assigning password to MySQL root user
# End
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
sudo apt-get -y install mysql-server
对于特定版本,例如mysql-server-5.6,您需要像这样指定版本:
For specific versions, such as mysql-server-5.6, you'll need to specify the version in like this:
sudo debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password_again password your_password'
sudo apt-get -y install mysql-server-5.6
对于 mysql-community-server,key 略有不同:
For mysql-community-server, the keys are slightly different:
sudo debconf-set-selections <<< 'mysql-community-server mysql-community-server/root-pass password your_password'
sudo debconf-set-selections <<< 'mysql-community-server mysql-community-server/re-root-pass password your_password'
sudo apt-get -y install mysql-community-server
将 your_password 替换为所需的 root 密码.(似乎 your_password 也可以为空白 root 密码留空.)
Replace your_password with the desired root password. (it seems your_password can also be left blank for a blank root password.)
如果您的 shell 不支持 here-strings(zsh、ksh93 和 bash 支持它们),使用:
If your shell doesn't support here-strings (zsh, ksh93 and bash support them), use:
echo ... | sudo debconf-set-selections
这篇关于在没有密码提示的情况下在 Ubuntu 上安装 MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何有效地使用窗口函数根据 N 个先前值来决定How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函数根据
在“GROUP BY"中重用选择表达式的结果;条款reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用选择表达式的结果;条款?)
Pyspark DataFrameWriter jdbc 函数的 ignore 选项是忽略整Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函数的 ig
使用 INSERT INTO table ON DUPLICATE KEY 时出错,使用 Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 时出错,使用 for 循环数组
pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 调用 o23.load 时发生错误 没有合适的
如何将 Apache Spark 与 MySQL 集成以将数据库表作为How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何将 Apache Spark 与 MySQL 集成以将数据库表作为