You can provision a MySQL database through either the Railway Dashboard or the Railway CLI.
Open dev.new and choose "Provision MySQL."
After the database is setup click "MySQL" on the left and then choose "Connect".
Download the MySQL command line client. If you're on a Mac you can use brew
.
brew install mysql
Your own password will be included in place of xxxx
.
mysql -hcontainers-us-west-8.railway.app -uroot -xxxx --port 7551 --protocol=TCP railway
Run the following SQL commands to create a test table with seed data.
CREATE TABLE test_table (Test text);
INSERT INTO test_table VALUES ('Hello'), ('Goodbye');
show tables;
Output:
+-------------------+
| Tables_in_railway |
+-------------------+
| test_table |
+-------------------+
1 row in set (0.04 sec)
First you need to install the Railway CLI.
curl -fsSL cli.new | sh
Check Railway CLI version.
railway -V
If you do not have a Railway account you will be prompted to create one.
railway login
Add --browserless
if you can't use a browser for logging in.
Run the following command to create a new Railway project called mysql-railway
.
railway init -n mysql-railway
Run the following command to add the MySQL plugin to your Railway project.
railway add -p mysql
railway link
Select your newly created mysql-railway
project from the list.
railway connect MySQL
Run the following SQL commands to create a test table with seed data.
CREATE TABLE Post (title text, body text);
INSERT INTO Post VALUES ('This is a blog post', 'Wooooooo');
INSERT INTO Post VALUES ('Another blog post', 'Even better than the other!');
SHOW TABLES;
+-------------------+
| Tables_in_railway |
+-------------------+
| Post |
+-------------------+
1 row in set (0.04 sec)
quit