To use SignalSQL, your application will initially establish a connection to the signal database and log in. The method for accomplishing this varies depending on the programming language used.
For instance, when using PHP, the connection establishment might look something like this:
<?php
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$database = "main";
// Create connection
$conn = new mysqli($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
// Other SignalSQL operations can now be performed using $conn
// Close connection when done
$conn->close();
?>
Replace “your_username” and “your_password” with your actual SignalSQL username and password.
After installation, a default user “root” with the password “signalsql” is present in SignalSQL. It is crucial to enhance security by changing the password for this user as the first step before utilizing SignalSQL in any connected environments. Update the password to a strong and secure one to ensure the integrity of your SignalSQL installation.
To connect to SignalSQL using Nodeand and the mysql2
library the following code can be used:
import * as mysql from 'mysql2/promise';
async function main() {
// Replace these values with your actual database credentials
const dbConfig: mysql.ConnectionOptions = {
host: 'localhost',
user: 'your_username',
password: 'your_password',
database: 'main',
};
// Create a connection pool
const pool = mysql.createPool(dbConfig);
try {
// Get a connection from the pool
const connection = await pool.getConnection();
// Perform database operations
const [rows, fields] = await connection.execute('SELECT * FROM input');
console.log('Query Result:', rows);
// Release the connection back to the pool
connection.release();
} catch (error) {
console.error('Error:', error.message);
} finally {
// Close the connection pool when done
pool.end();
}
}
main();
Remember to replace 'your_username'
and 'your_password'
with your actual SignalSQL credentials.
Managing users
To change the password of a user in SignalSQL, execute the following SQL command:
UPDATE system.user SET Password = 'new_password' WHERE Username = 'your_username'
Replace 'new_password'
with the desired new password, and 'your_username'
with the username for which you want to change the password.
To create a new user in SignalSQL, execute the following SQL command.
INSERT INTO system.user VALUES (0,'your_username','your_password')
Replace 'your_password'
with the desired password, and 'your_username'
with the username for the new user.